Role:
I did everything except for the artwork (Made by Sarah Sneeboer).
Employment duration:
2 Months (1 April 2014 – 1 June 2014)
Company:
HKU (School graduation project)
Engine:
Unity3D (using C#)
Summary:
Grown Apart is the graduation project I created while graduating as a Bachelor with honours from the Utrecht School of Art and Technology. It is a new IP based on the sociological principle of friends growing apart and becoming enemies.
I did research on how people become friends, grow apart and become enemies. I concluded that in order to become friends people require a common status and goal, whereas enemies differ in status and goals. Furthermore people grow apart when they tend to make selfish choices (anti-social behaviour) rather than mutually beneficial ones (pro-social behaviour).
The game itself pits 4 players against a violent world in which the goal is to defeat the final boss. During the game they are constantly tempted to choose for their own personal benefit.
All the elements in the game are tailored to help a single person, but at the same time make it harder on the rest of the team. For example: There is an item that drops a portal in front of the player who used the item. When enemies collide with the portal, they are teleported away from the user (beneficial to the user) to a random other player (detrimental to the player). As I noticed in the playtests, the gameplay makes for some really entertaining moments!
The catch however is that players start as friends (no friendly fire and shared victory) but can become solo if they give in to temptation (free-for-all and solo victory condition). This effect creates a dynamic playground where every player has a chance to win the game, either by cooperating or by competiting. The choice is up to the player!
The challenge in the game is to cope with the changes and events that happen while playing, yet still be contributing towards primary goal of defeating the final boss.
Within the game the players have to collect resources to progress through the different stages of the game (based on the 4X principle of explore, expand, exploit and exterminate) which they can spend on abilities and weapons that they can buy in a shop. This creates the possibility for players to create a unique play style that is tailored towards their situation and personal goals within each specific match.
Responsibilities:
- Designed and documented the core concept and mechanics.
- Researched the sociological concepts of people becoming friends, enemies and how people grow apart.
- Designed and made a total of 5 enemies and one final boss enemy that has randomized attacks.
- Designed and made a total of 9 unique weapons that can be picked up and dropped.
- Established a system for modular abilities that alter the gameplay, gameflow and controls directly and that can be picked up and dropped.
- Made a bonding system that tracks if a player is alone and isolated. If the bond is lost and a player dies, he will join the final boss and battle the rest of the players in pvp.
- Made a ‘dead player’ class. That has unique (stealth) abilities aimed at taking down the remaining players. This dramatically changes the way the game is played.
- Made the networking and game work on Windows, Mac & Linux.
- Made an final boss that has a fixed set of attacks, that are randomly chosen whenever an eye is hit, or when the game starts.
- Designed and made a total of 4 game altering abilities that the final boss can use locally and globally.
- Designed a micro-transaction system for character customization.
- Designed and implemented a resources system and a shop to spend the resources.
- Made a day & night cycle. Enemies spawn at night.
- Made a 2D level design and environment
- Made a system that procedural generates the level. Including paths.
Including: Parallax scrolling, dynamic lights, sprites and materials, animations, modular level sections, particles, and more.
Media:
Random level generation: Uses a lookuptable written in C# and compiled once to XML, after that it can read it fast from XML and generate a level using prefabs

Lookuptable script that writes to XML:
using UnityEngine;
using System.Collections;
public class Lookuptable : MonoBehaviour {
private static int[,,] lut;
// Bottom neighbour : #0, Right # 1, Top #2 Left #3
void Awake()
{
fillLUT();
editLUT();
}
void editLUT() // removes end to end connections
{
lut[0, 4, 1] = -1;
lut[1, 8, 2] = -1;
lut[2, 1, 4] = -1;
lut[3, 2, 8] = -1;
}
void fillLUT() //Unchanged LUT generator. Makes LUT like in excel.
{
int numOfNeighbourPos = 4;
int numOfTileTypes = 16;
lut = new int[numOfNeighbourPos,numOfTileTypes,numOfTileTypes];
for(int neighbourPos = 0; neighbourPos
Level generation script:
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class Generatelevel : MonoBehaviour {
public int[,] tileIDlist; //List of all tile IDs
public string[] levelnames; //possible options for a tile, names are strings to be used for spawning prefabs
private int[] candidates = new int[16]; //candidate list for possible tile options
private int neighbourcounter = 0; //amount of neighbours
private int tileTypes = 16; //amount of tiletypes
private int width = 11; //width of the level grid in amount of tiles
private int height = 11; //height of the level grid in amount of tiles
private System.Random rnd; //random number
private Vector2 position = new Vector2(0,0);//spawn position
private List finalcandidates; //final candidates from the original candidates
//boundaries
private int highestwidth;
private int highestheight;
private int centerwidth;
private int centerheight;
//size of a single tile
private int offsetX = 110;
private int offsetY = 54;
void Start()
{
if(Network.isClient)
{
Destroy(this);
}
rnd = new System.Random();
highestwidth = width - 1;
highestheight = height - 1;
centerwidth = highestwidth / 2;
centerheight = highestheight / 2;
fillLevelNames();
}
void OnGUI()
{
if (GUI.Button(new Rect(10, 50, 150, 100), "Regenerate level"))
{
ReGeneratelevels();
}
}
void ReGeneratelevels()
{
foreach (GameObject tileobject in GameObject.FindGameObjectsWithTag("Tile"))
{
Destroy(tileobject);
}
clearTiles();
makeCorners();
manualSetup();
fillTiles();
replaceTileWithBoss(centerwidth, centerheight);
instatiateAllTiles();
}
void Generatelevels()
{
if(Network.isClient)
{
Destroy(this);
}
// levelnames = new string[tileTypes];
// levelnames[0] = "tile0000";
// levelnames[1] = "tile0001";
// levelnames[2] = "tile0010";
// levelnames[3] = "tile0011";
// levelnames[4] = "tile0100";
// levelnames[5] = "tile0101";
// levelnames[6] = "tile0110";
// levelnames[7] = "tile0111";
// levelnames[8] = "tile1000";
// levelnames[9] = "tile1001";
// levelnames[10] = "tile1010";
// levelnames[11] = "tile1011";
// levelnames[12] = "tile1100";
// levelnames[13] = "tile1101";x
// levelnames[14] = "tile1110";
// levelnames[15] = "tile1111";
finalcandidates = new List();
tileIDlist = new int[width, height];
clearTiles();
makeCorners();
manualSetup();
fillTiles();
replaceTileWithBoss(centerwidth,centerheight);
instatiateAllTiles();
}
void fillLevelNames()
{
int totalTiles = tileTypes;
levelnames = new string[totalTiles*2];
string tempstring;
for (int nr = 0; nr < totalTiles; nr++)
{
tempstring = "tile" + nr;
levelnames[nr] = tempstring;
}
for (int snr = totalTiles; snr < totalTiles*2; snr++)
{
tempstring = "bosstile" + snr;
levelnames[snr] = tempstring;
}
}
void clearTiles()
{
for (int x = 0; x < width; x++)
{
for (int y = 0; y < height; y++)
{
tileIDlist[x, y] = -1;
}
}
}
void manualSetup() //use this to manually control level generation
{
makeTile(centerwidth,centerheight,15);
makePath(highestwidth-1,highestheight-1,centerwidth,centerheight);
makePath(1,1,centerwidth,centerheight);
makePath(highestwidth-1,1,centerwidth,centerheight);
makePath(1,highestheight-1,centerwidth,centerheight);
// MAKEPATH type commands come here: Use to make specific paths fixed for example:
//makeTile (8,1,0);
//makePath (1,1,8,1);
//makePath (1,2,8,2);
//makePath (1,1,8,8);
//makePath (1,8,8,1);
//makeTile(highestwidth-1,highestheight-1,15);
//makePath(0,1,4,3);
//makeTile(1,highestheight-1,15);
//makePath(0,1,4,3);
//makeTile(highestwidth-1,1,15);
//makePath(0,1,4,3);
//makePath(0,1,4,3);
//tileIDlist[2,3] = 15;
//tileIDlist[4,3] = 2;
//tileIDlist[1,3] = 2;
}
void makeTile(int x, int y, int tiletype)
{
tileIDlist[x,y] = tiletype;
}
void makeCorners() //makes the 4 corners
{
for (int x = 0; x < width; x++)
{
for (int y = 0; y < height; y++)
{
if (x == 0 && y == 0 || x == highestwidth && y == 0)
{
tileIDlist[x, y] = 10;
Debug.Log("Found bottom corners");
}
if (x == 0 && y == highestheight || x == highestwidth && y == highestheight)
{
tileIDlist[x, y] = 11;
Debug.Log("Found Top corners");
}
}
}
}
bool tileIsFull(int x, int y) // return true if tile is full, false if tile empty
{
if (tileIDlist[x, y] > -1)
{
Debug.Log("Already found a tile at (x,y): " + "(" + x + "," + y + "). No new tile made");
return true;
}
return false;
}
void fillTileAt(int x, int y)
{
resetcandidates();
if (tileIsFull(x,y))
{
}
else
{
findCandidatesDueToAll(x, y);
pickCandidate(x, y);
}
}
void replaceTile(int x,int y)
{
if(tileIDlist[x,y] == -1){Debug.LogWarning("Replace tile called on empty tile: "+"("+x+","+y+"). Doing nothing"); return;}
Debug.LogWarning("Overwriting filled tile: "+"("+x+","+y+")");
Debug.LogWarning("Tile was: "+ tileIDlist[x,y]);
tileIDlist[x,y] = -1;
fillTileAt(x,y);
}
void replaceTileWithBoss(int x, int y)
{
if (tileIsFull(x, y))
{
tileIDlist[x, y] = tileIDlist[x, y] + tileTypes;
}
}
bool fillPathTileAt(int direction, int x, int y) // direction: 1 right, 2 up no other arguments (can't go down/ left)
{
resetcandidates();
if (tileIsFull(x,y))
{
return false;
}
else
{
if (direction == 1)
{
for (int n = 0; n < tileTypes; n++)
{
if (gameObject.GetComponent().isRightPath(n))
{
}
else
{
candidates[n] = -1;
}
}
}
if (direction == 2)
{
for (int n = 0; n < tileTypes; n++)
{
if (gameObject.GetComponent().isUpPath(n))
{
}
else
{
candidates[n] = -1;
}
}
}
findCandidatesDueToAll(x, y);
pickCandidateForPath(x, y);
return true;
}
}
void fillTiles() //fills non preset tiles with random allowed tiles
{
for(int x = 0;x 0)
{
lookForCandidatesDue(3, x - 1, y);
}
else
{
lookForCandidatesDue(3, highestwidth, y);
}
}// NOT STANDALONE find the candidates for the Tile at x,y due to the tile to the right in all non corner cases
void lookForCandidatesDue(int otherrelative, int otherx, int othery)// overfill candidates[]. Elimination required after. Input: Other tile relative position( bottom: 0, right 1, top 2, left 3), other tile x,y coord.
{
if (othery > -1 && othery < highestheight + 1 && otherx > -1 && otherx < highestwidth + 1)
{
if (tileIDlist[otherx, othery] == -1) { return; } // no neighbour
else{
neighbourcounter++;
for (int counter = 0; counter < tileTypes; counter++)
{
if (candidates[counter] == gameObject.GetComponent().Lookup(otherrelative, tileIDlist[otherx, othery], counter))
{
if (candidates[counter] == -1)
{
Debug.LogWarning("candidates[" + counter + "] was -1"); //not always a bug, but can indicate one
}
else
{
candidates[counter] = counter; // allow option
}
}
else
{
candidates[counter] = -1; //delete that option
}
}
}
}
else if (othery == -1 || othery == highestheight + 1) //bug // unfinished
{
neighbourcounter++;
for (int counter = 0; counter < tileTypes; counter++)
{
if (candidates[counter] == gameObject.GetComponent().Lookup(otherrelative, 0, counter))
{
if (candidates[counter] == -1)
{
Debug.LogWarning("candidates[" + counter + "] was -1"); //not always a bug, but can indicate one
}
else
{
candidates[counter] = counter; // allow option
}
}
else
{
candidates[counter] = -1; //delete that option
}
}
}
else
{
Debug.LogError("Something Somewhere asked lookForCandidatesDue() for out of bound Tile numbers" + otherx + othery);
}
}
void pickCandidate(int x, int y, bool path = false) //after candidates[] is fully generated, picks a possible candidate at random and sets tile value to it. Default: 0
{
for (int candnr = 0; candnr < tileTypes; candnr++)
{
if (candidates[candnr] > -1)
{
finalcandidates.Add(candidates[candnr]);
}
}
if (finalcandidates.Count == 0)
{
Debug.Log("No candidates found!");
if(path)
{
tileIDlist[x,y] = 15;
replaceTile(x-1,y);
replaceTile(x+1,y);
replaceTile(x,y-1);
replaceTile(x,y+1);
}
else tileIDlist[x,y] = 0;
// if in a path, make sure you can overwrite the neighbouring tiles.
}
else
{
int randomnumber = Random.Range(0, finalcandidates.Count - 1);
tileIDlist[x, y] = finalcandidates[randomnumber];
if (tileIDlist[x, y] == -1) // should never happen
{
Debug.LogError("Failed to fill the tile! at index: " + x + y);
}
}
}
void pickCandidateForPath(int x, int y) //after candidates[] is fully generated, picks a possible candidate at random and sets tile value to it. Default: 0
{
pickCandidate(x,y,true);
}
void instatiateAllTiles(){
for(int x = 0; x < width; x++)
{
for(int y = 0 ; y < height; y++){
instantiateTile(x,y);
}
}
}
private void instantiateTile(int x, int y)
{
if(tileIDlist[x,y] > tileTypes*2 -1 || tileIDlist[x,y] < 0)
{
Debug.LogError("Attempted to instantiate an invalid tileID at: " + x + y);
return;
}
string level = "Level segments/" + levelnames[tileIDlist[x,y]];
GameObject chosenlevel = Resources.Load(level);
position.Set(x * offsetX, y * offsetY);
Debug.Log(level);
Network.Instantiate(chosenlevel, position, Quaternion.identity, 0);
Debug.Log("Placed object of type | i | y : " + tileIDlist[x, y] + " | " + x + " | " + y);
}
private void resetcandidates() // resets candidates[] and finalcandidates();
{
finalcandidates.Clear();
neighbourcounter = 0;
for(int i = 0;i highestwidth) { Debug.LogError("bad make"+direction+"Path called; x1 too big"); Debug.LogError("x0,y0,x1,y1: "+x0+"|"+y0+"|"+x1+"|"+y1);return false; } //check for user error
if (y0 < 0) { Debug.LogError("bad make"+direction+"Path called; y1 too small"); Debug.LogError("x0,y0,x1,y1: "+x0+"|"+y0+"|"+x1+"|"+y1);return false; } //check for user error
if (y1 > highestheight) { Debug.LogError("bad make"+direction+"Path called; y1 too big"); Debug.LogError("x0,y0,x1,y1: "+x0+"|"+y0+"|"+x1+"|"+y1);return false; } //check for user error
return true;
}
//VEILGIST OM makePath te gebruiken. Onderstaande functies zijn (innie beetje) sneller als je exact weet wat je wilt doen).
bool makeRightUpPath(int x0, int y0, int x1, int y1)//make path from x0,y0 to x1,y1 where x0 direction) //Go Up
{
currenty = goUp (currentx, currenty);
if(currenty == -1){ return false;};
}
else if( r < direction)//Go Right
{
currentx = goRight (currentx, currenty);
if(currentx == -1){ return false;};
}
else
{
Debug.LogError("No direction could be chosesn in makeRightUpPath, defaulting to go right");
// true if no tile hit while making path, false if tile hit
currentx = goRight (currentx, currenty);
if(currentx == -1){ return false;};
}
}
return true;
}
return false;
}// end of makeRight up Path
bool makeRightDownPath(int x0, int y0, int x1, int y1)
{
if(!checkMakePathWillWork(x0,y1,x1,y0,"RightDown")){return false;}
else
{
int xdif = x1 - x0;
int ydif = y0 - y1;
int stepstomake = xdif + ydif +1;
int currentx = x0;
int currenty = y0;
double r = -1;
double direction = (double)xdif / (double)stepstomake; // bug sensitive
for (int step = 0; step < stepstomake; step++)
{
Debug.Log (currentx);
Debug.Log (currenty);
r = rnd.NextDouble();
if (currentx == x1) // Go Down
{
currenty = goDown (currentx, currenty);
if(currenty == -1){ return false;}
}
else if (currenty == y1) // Go right
{
currentx = goRight (currentx, currenty);
if(currentx == -1){ return false;}
}
else if (r < direction) //Go Down
{
currenty = goDown (currentx, currenty);
if(currenty == -1){ return false;}
}
else//Go Right
{
currentx = goRight (currentx, currenty);
if(currentx == -1){ return false;}
}
Debug.Log (currentx);
Debug.Log (currenty);
}
return true;
}
}
bool makeLeftDownPath(int x0, int y0, int x1, int y1)
{
//return makeRightUpPath(x1, y1, x0, y0); // deliberate inverse, not a mistake (don't fix !!!)
if(!checkMakePathWillWork(x1,y1,x0,y0,"LeftDown")){return false;}
else
{
int xdif = x0 - x1;
int ydif = y0 - y1;
int stepstomake = xdif + ydif + 1;
int currentx = x0;
int currenty = y0;
double r = -1;
double direction = (double)xdif / (double)stepstomake; // bug sensitive
for (int step = 0; step < stepstomake; step++)
{
Debug.Log (currentx);
Debug.Log (currenty);
r = rnd.NextDouble();
if (currentx == x1) // Go Down
{
currenty = goDown (currentx, currenty);
if(currenty == -1){ return false;}
}
else if (currenty == y1) // Go Left
{
currentx = goLeft (currentx, currenty);
if(currentx == -1){ return false;}
}
else if (r < direction) //Go Down
{
currenty = goDown (currentx, currenty);
if(currenty == -1){ return false;}
}
else//Go Left
{
currentx = goLeft (currentx, currenty);
if(currentx == -1){ return false;}
}
}
return true;
}
}
bool makeLeftUpPath(int x0, int y0, int x1, int y1)
{
if(!checkMakePathWillWork(x1,y0,x0,y1,"LeftUp")){return false;}
else
{
int xdif = x0 - x1;
int ydif = y1 - y0;
int stepstomake = xdif + ydif + 1;
int currentx = x0;
int currenty = y0;
double r = -1;
double direction = (double)xdif / (double)stepstomake; // bug sensitive
for (int step = 0; step < stepstomake; step++)
{
Debug.Log (currentx);
Debug.Log (currenty);
r = rnd.NextDouble();
if (currentx == x1) // Go UP
{
currenty = goUp (currentx, currenty);
if(currenty == -1){ return false;}
}
else if (currenty == y1) // Go Left
{
currentx = goLeft (currentx, currenty);
if(currentx == -1){ return false;}
}
else if (r < direction) //Go Up
{
currenty = goUp (currentx, currenty);
if(currenty == -1){ return false;}
}
else//Go Left
{
currentx = goLeft (currentx, currenty);
if(currentx == -1){ return false;}
}
}
return true;
}
}
}
Menu and visual update:
Graduation trailer:
Code samples from Grown Apart:
- A parent classs inheritence script called SkillClass for variable inheritence and functions required by the skills
using UnityEngine;
using System.Collections;
public class SkillClass : MonoBehaviour {
public int cost; //the cost to buy this skill in store
public string displayname; //the skill name
public int weaponplace; //the place this weapon would go (skill, melee or ranged)
public float influence; //is this skill a solo or team benefit, and how much
public bool breakdamage; //can the damage done by this skill break objects?
//activate the skill
public virtual void Startshooting()
{
}
//change the cooldown time
public virtual void changecooldown(float time)
{
}
}
- A subclass from the parent that adds functions to be used if the skill is from its type
using UnityEngine;
using System.Collections;
public class MovementSkillsClass : SkillClass
{
// Move the character to a point in space over a duration
public IEnumerator MoveTowards(Vector3 newposition, float duration)
{
Vector3 curPos = transform.position;
Vector3 newPos = newposition;
for (float t = 0; t < 1;)
{
t += Time.deltaTime / duration;
transform.position = Vector3.Lerp(curPos, newPos, t);
yield return null;
}
yield break;
}
//move the character to a point in space over a duration and afterwards to a second point
public IEnumerator MoveTowards(Vector3 newposition, Vector3 secondnewposition, float durationfirst, float durationsecond)
{
Vector3 curPos = transform.position;
Vector3 newPos = newposition;
for (float t = 0; t < 1;)
{
t += Time.deltaTime / durationfirst;
transform.position = Vector3.Lerp(curPos, newPos, t);
yield return null;
}
curPos = newPos;
newPos = secondnewposition;
for (float t = 0; t < 1;)
{
t += Time.deltaTime / durationsecond;
transform.position = Vector3.Lerp(curPos, newPos, t);
yield return null;
}
yield break;
}
}
- A child class that uses the functions from the parent (subclass) to do a skill move
using UnityEngine;
using System.Collections;
public class DoubleFlashSkill : MovementSkillsClass {
private LayerMask WhatIsGround; //what colliders can this skill use in its movement calculations
private float cooldowntime = 1f; //the global cooldown
private bool canshoot = true; //can the skill be used?
private float dy = 5f; //distance to move over the y axis
void Start ()
{
//set skillclass values
displayname = "Double flash";
cost = 100;
weaponplace = 2;
influence = -0.2f;
WhatIsGround = ((1 << 0) | (1 << 4)| (1 << 18) | (1 << 19));
}
//activate the skill
public override void Startshooting()
{
//if the skill is not on a cooldown, create the movement path and check if the move is possible. Stop movement if colliding
if(canshoot)
{
float dx = transform.FindChild("bulletlaunch").transform.localPosition.x * 5f;
Vector3 movepoint = new Vector3(transform.position.x,transform.position.y + dy,0);
Vector3 movepointsecond = new Vector3(transform.position.x + dx,transform.position.y + dy,0);
RaycastHit2D hitcheck = Physics2D.Raycast(movepointsecond,Vector2.right*-2.5f,5f,WhatIsGround);
if(!hitcheck)
{
float cooldownduration = 0.2f;
StartCoroutine(Cooldown());
StartCoroutine(MoveTowards(movepoint,movepointsecond,cooldownduration,cooldownduration));
}
}
}
//take care of the global cooldown
IEnumerator Cooldown()
{
canshoot = false;
yield return new WaitForSeconds(cooldowntime);
canshoot = true;
}
//change the global cooldown
public override void changecooldown(float time)
{
cooldowntime+= time;
}
}
- the weapon inventory system that calls the functions displayed in the class scripts above
using UnityEngine;
using System.Collections;
public class Arsenal : MonoBehaviour {
private int[] activeweapons; //array that holds the weapons and abilities sgained by to this character
private SkillClass[] allweapons; //array that holds reference to all weapons and abilties
private bool firstweaponactive; //if the first or second weapon is currently active
void Awake ()
{
// all weapon and ability scripts.
allweapons = new SkillClass[12];
allweapons[0] = gameObject.GetComponent(); //melee weapon
allweapons[1] = gameObject.GetComponent(); //ranged weapon
allweapons[2] = gameObject.GetComponent(); //ranged weapon
allweapons[3] = gameObject.GetComponent(); //melee weapon
allweapons[4] = gameObject.GetComponent(); //melee weapon
allweapons[5] = gameObject.GetComponent(); //ranged weapon
allweapons[6] = gameObject.GetComponent(); //ranged weapon
allweapons[7] = gameObject.GetComponent(); //ranged weapon
allweapons[8] = gameObject.GetComponent(); //melee weapon
allweapons[9] = gameObject.GetComponent(); //melee weapon
allweapons[10] = gameObject.GetComponent(); //melee weapon
//disable all scripts
for(int i = 0; i < 11; i++)
{
allweapons[i].enabled = false;
}
if(GetComponent().isMine)
{
activeweapons = new int[6];
activeweapons[0] = 0; //melee weapon
activeweapons[1] = 1; // ranged weapon
activeweapons[2] = -1; // attack one
activeweapons[3] = -1; // attack two
activeweapons[4] = -1; // attack three
activeweapons[5] = -1; // attack four
//only make the firstweapon active;
allweapons[0].enabled = true;
allweapons[1].enabled = false;
firstweaponactive = true;
}else{
this.enabled = false;
}
}
void Update()
{
//check for input: should be done using unity InputManager! Change this
Debug.LogWarning("you need to change the input to InputManager instead!");
//activate current active weapon
if(Input.GetMouseButtonDown(0))
{
if(firstweaponactive == true)
{
allweapons[activeweapons[0]].Startshooting();
}else
{
allweapons[activeweapons[1]].Startshooting();
}
}
//switch weapon from melee to ranged
if(Input.GetKeyUp("q"))
{
firstweaponactive=!firstweaponactive;
if(activeweapons[0] > -1 && activeweapons[1] > -1){
allweapons[activeweapons[0]].enabled = firstweaponactive;
allweapons[activeweapons[1]].enabled = !firstweaponactive;
}
}
//active the first ability
if(Input.GetKeyUp("1"))
{
if(activeweapons[2] > -1)
{
allweapons[activeweapons[2]].Startshooting();
}
}
//active the second ability
if(Input.GetKeyUp("2"))
{
if(activeweapons[3] > -1)
{
allweapons[activeweapons[3]].Startshooting();
}
}
//active the third ability
if(Input.GetKeyUp("3"))
{
if(activeweapons[4] > -1)
{
allweapons[activeweapons[4]].Startshooting();
}
}
//active the fourth ability
if(Input.GetKeyUp("4"))
{
if(activeweapons[5] > -1)
{
allweapons[activeweapons[5]].Startshooting();
}
}
}
//use this function to switch a weapons position
public void switchweapon(int oldplace, int newplace)
{
int tempoldplaceweapon = activeweapons[oldplace];
int tempnewplaceweapon = activeweapons[newplace];
activeweapons[oldplace] = tempnewplaceweapon;
activeweapons[newplace] = tempoldplaceweapon;
Debug.Log("changed weapon slot from: "+ oldplace + "to: " + newplace);
}
//use this function to add a new weapon
public void addweapon(int place, int weapon)
{
if(activeweapons[place] == -1)
{
activeweapons[place] = weapon;
allweapons[activeweapons[place]].enabled = true;
Debug.Log("Added weapon: " + weapon + "At place: " + place);
}else{
replaceweapon(place,weapon);
}
}
//use this function to replace a weapon
public void replaceweapon(int place, int weapon)
{
allweapons[activeweapons[place]].enabled = false;
activeweapons[place] = weapon;
allweapons[activeweapons[place]].enabled = true;
Debug.Log("Replaced weapon at spot: " + place + "with a new weapon of type: " + weapon);
}
// drop the current weapon !WARNING! This feature has been removed from the game
// public void dropweapon()
// {
// if(currentmeleeweapon != null){
// gameObject.SendMessage("Destroymeweapon",SendMessageOptions.RequireReceiver);
// gameObject.AddComponent("Meleeweapon");
// currentmeleeweapon = "Meleeweapon";
// }
// if(currentrangedweapon != null)
// {
// gameObject.SendMessage("Destroymetrap",SendMessageOptions.RequireReceiver);
// currentrangedweapon = null;
// }
//}
}

