Esempio n. 1
0
    public static void FindBuildTower(int direction, FieldIndex ind, Field<bool> taken, ref List<Tower> buildList)
    {
        //Debug.Log("Finding 2nd piece forward on "+tmp.ToString());
        Tower newTower = new Tower();
        FieldIndex tmp = ind.Up(direction);
        newTower.Add(ind);
        newTower.Add(tmp);
        newTower.type = TowerType.build;
        ind = tmp;
        tmp = ind.Up(direction);

        if(tmp.index != -1 && taken[tmp]==true){
            //Debug.Log("Finding 3rd piece forward on "+tmp.ToString());
            newTower.Add(tmp);
            ind = tmp;
            FieldIndex left = ind.Left(direction);
            FieldIndex right = ind.Right(direction);
            bool left_tower = left.index != -1 && taken[left] == true;
            bool right_tower = right.index != -1 && taken[right] == true;
            if(left_tower && right_tower){ //Left and right turn build tower.
                Tower rightTower = newTower.Copy();
                newTower.Add(left);
        //				Debug.Log(newTower.ToString());
                rightTower.Add(right);
        //				Debug.Log(rightTower.ToString());
                buildList.Add(newTower);
                buildList.Add(rightTower);
            }else if(left_tower){			//Left turn build tower.
                newTower.Add(left);
        //				Debug.Log(newTower.ToString());
                buildList.Add(newTower);
            }else if(right_tower){			//Right turn build tower.
                newTower.Add(right);
        //				Debug.Log(newTower.ToString());
                buildList.Add(newTower);
            }
        }
    }
Esempio n. 2
0
 public static void FindShootTower(int direction, FieldIndex ind, Field<bool> taken, ref List<Tower> buildList)
 {
     //Debug.Log("Finding 2nd piece forward on "+tmp.ToString());
     Tower newTower = new Tower();
     FieldIndex tmp = ind.Up(direction);
     newTower.Add(ind);
     newTower.Add(tmp);
     newTower.type = TowerType.shoot;
     ind = tmp;
     FieldIndex left = ind.Left(direction);
     FieldIndex right = ind.Right(direction);
     bool left_tower = left.index != -1 && taken[left] == true;
     bool right_tower = right.index != -1 && taken[right] == true;
     if(left_tower && right_tower){ //Shoot tower found.
         newTower.Add(left);
         newTower.Add(right);
     //			Debug.Log(newTower.ToString());
         buildList.Add(newTower);
     }
 }