//this is for adding the upgrade onto the weapon stats
 public weaponProperties add(weaponProperties original, weaponProperties upgrade)
 {
     weaponProperties final = new weaponProperties();
     final.damage = original.damage + upgrade.damage;
     final.special = string.Concat (original.special, upgrade.special);
     final.spAmount = original.spAmount + upgrade.spAmount;
     final.range = original.range + upgrade.range;
     final.delay = original.delay + upgrade.delay;
     return final;
 }
 //it should be a constructor:
 public void giveValue(weaponProperties weapon)
 {
     damage = weapon.damage;
     delay = weapon.delay;
     range = weapon.range;
     special = weapon.special;
     spAmount = weapon.spAmount;
     weaponName = weapon.weaponName;
     lifeTime = weapon.lifeTime;
     expReturn = weapon.expReturn;
 }
 //I haven't examined this bit for a long time
 //Just pretend it doesn't exist
 //This is supposed to be somewhere to store info on all the upgrade
 void Start()
 {
     upgrade = this.gameObject.AddComponent <weaponProperties>();
     upgrade.damage = damage;
     upgrade.range = range;
     upgrade.delay = delay;
     upgrade.special = special;
     upgrade.spAmount = spAmount;
     controller = GameObject.Find("gameData");
     sctrl = controller.GetComponent<statsController> ();
     isValid = new bool[sctrl.maxWeapons];
 }
 void Start()
 {
     action = GameObject.Find("actionController");
     actrl = action.GetComponent<actionController> ();
     stats = this.GetComponent<weaponProperties> ();
     rend = GetComponent<Renderer> ();
     if (stats.damage <0) {
         rend.material.color = Color.green;
     } else {
         rend.material.color = Color.red;
     }
     t = actrl.time;
 }
    void initializeData(int currentPlayer)
    {
        //start processing attack data received to this part of the program

        int i,j=0;
        int d;

        maxAction = findMaxAction (playerMove);

        Vector2[,] attackPlan = new Vector2[10,maxAction+1];
        weaponProperties[,] weapons = new weaponProperties[10,maxAction+2]; //size determined by the max weapon delay - I assume it's no larger than 1
        int currentWeapon;

        for(i=0;i<maxAction;i++){
            if (i<playerMove[currentPlayer].attack.Count){
                currentWeapon=playerMove[currentPlayer].weapon[i];

                if(currentWeapon!=0){
                    if(dataBase.weapons[currentWeapon].delay==Mathf.Infinity) {
                        d = maxAction-i;
                    }else{
                        d = Mathf.RoundToInt(dataBase.weapons[currentWeapon].delay);
                    }

                    for(j=0;j<=maxAction;j++){
                        if (attackPlan[i+d,j]==Vector2.zero){
                            attackPlan[i+d,j]=playerMove[currentPlayer].attack[i];
                            weapons[i+d,j]=dataBase.updateWeaponStats(currentWeapon,upgradeOn);
                            break;
                        }
                    }
                }
            }else{

            }
        }
        weaponsList.Add (weapons);
        toInstantiate.Add (attackPlan);
        return;
    }
    void fireWeapon(weaponProperties weapon, Vector2 position)
    {
        //calculate what type of collision sphere to generate
        bomb (weapon, position);
        string sp = weapon.special;
        weaponProperties tempWeapon = this.gameObject.AddComponent<weaponProperties>();
        tempWeapon.giveValue (weapon);
        if(sp.IndexOf("aoe")!=-1){
            string temp=sp.Substring(sp.IndexOf("aoe")+3);
            int aoeSize = int.Parse(temp.Substring(0,temp.IndexOf(",")));
            print ("Aoesize="+aoeSize);
            temp = temp.Substring(temp.IndexOf(",")+1);
            int aoeDamage = int.Parse(temp.Substring(0,temp.IndexOf(";")));
            temp = temp.Substring(sp.IndexOf(";")+1);
            tempWeapon.damage = aoeDamage;
            if (sp.IndexOf("push")!=-1){
                for (int i=0;i<6;i++){
                    tempWeapon.special = "go" + Mathf.RoundToInt(dataBase.directions[i].x).ToString()+","+ Mathf.RoundToInt(dataBase.directions[i].y).ToString()+";";
                    bomb (tempWeapon,position+dataBase.directions[i]);
                }
                print(tempWeapon.special);
            }
        }else{

        }
    }
 void bomb(weaponProperties weapon, Vector2 position)
 {
     //where the collision sphere is actually created
     GameObject dmgGlobe = Instantiate (damageCollider, gctrl.positionTransform (position), Quaternion.identity)as GameObject;
     weaponProperties dmgWeapon = dmgGlobe.GetComponent<weaponProperties>();
     damageGlobe dmgInfo = dmgGlobe.GetComponent<damageGlobe>();
     dmgWeapon.giveValue (weapon);
     dmgInfo.origin = this.gameObject;
     print("dmgGenerated");
 }