Ejemplo n.º 1
0
    public static void FindEmpTower(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.silence;
        ind = tmp;
        FieldIndex right = ind.Right(direction);
        FieldIndex left = ind.Left(direction);
        bool left_tower = left.index != -1 && taken[left] == true;
        bool right_tower = right.index != -1 && taken[right] == true;
        if(left_tower && right_tower){
        //			Debug.Log("Finding 3rd piece forward on "+tmp.ToString());
            Tower rightTower = newTower.Copy();

            newTower.Add(left);
            //Debug.Log(newTower.ToString());
            rightTower.Add(right);
            //Debug.Log(rightTower.ToString());

            tmp = left.Up(direction);
            FieldIndex tmpRight = right.Up(direction);

            if(tmp.index != -1 && taken[tmp]==true){
                newTower.Add(tmp);
        //				Debug.Log(newTower.ToString());
                buildList.Add(newTower);
            }
            if(tmpRight.index != -1 && taken[tmpRight]==true){
                rightTower.Add(tmpRight);
        //				Debug.Log(newTower.ToString());
                buildList.Add(rightTower);
            }
        }
        else if(left_tower){
            newTower.Add(left);
            tmp = left.Up(direction);

            if(tmp.index != -1 && taken[tmp]==true){
                newTower.Add(tmp);
        //				Debug.Log(newTower.ToString());
                buildList.Add(newTower);
            }
        }
        else if(right_tower){
            newTower.Add(right);
            tmp = right.Up(direction);

            if(tmp.index != -1 && taken[tmp]==true){
                newTower.Add(tmp);
        //				Debug.Log(newTower.ToString());
                buildList.Add(newTower);
            }
        }
    }
Ejemplo n.º 2
0
    public static List<Tower> FindTower( Field<bool> taken)
    {
        List<Tower> buildList = new List<Tower>();
        for( int i = 0; i < Stats.fieldSize*Stats.fieldSize; i++){
            if( taken[i] == true ){

                //Debug.Log("starting from "+new FieldIndex(i).ToString());
                for( int j = 0; j<8; j++){	//all directions
                    FieldIndex ind = new FieldIndex(i);
                    FieldIndex tmp = ind.Up(j);

                    if(tmp.index != -1 && taken[tmp]==true){ //If true; there might be towers.
                        //checks with Stats if the towers has been disabled:
                        if((j%2==1 && Stats.skillEnabled.diagBuild ) || (j%2==0 && Stats.skillEnabled.build)){ // build
                            FindBuildTower(j, ind, taken, ref buildList);
                        }if((j%2==1 && Stats.skillEnabled.diagShoot) || ( j%2==0 && Stats.skillEnabled.shoot)){ // shoot
                            FindShootTower(j, ind, taken, ref buildList);
                        }if(j<4){
                            if((j%2==1 && Stats.skillEnabled.diagSilence) || ( j%2==0 && Stats.skillEnabled.silence)){ // silence
                                FindEmpTower(j, ind, taken, ref buildList);
                            }
                            if((j%2==1 && Stats.skillEnabled.diagFive) || ( j%2==0 && Stats.skillEnabled.five)){
                                FindFiveTower(j, ind, taken, ref buildList);
                            }
                        }
                        if(j>5 && ((j%2==1 && Stats.skillEnabled.diagSkillCap) || (j%2==0 && Stats.skillEnabled.skillCap))){ // square
                            FindSquareTower(j, ind, taken, ref buildList);
                        }

                    }

                }
            }
        }
        return buildList;
    }
Ejemplo n.º 3
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);
     }
 }
Ejemplo n.º 4
0
    public static void FindSquareTower(int direction, FieldIndex ind, Field<bool> taken, ref List<Tower> buildList)
    {
        Tower newTower = new Tower();
        newTower.type = TowerType.skillCap;
        //Debug.Log("Found 2nd piece forward on "+ind.ToString());
        newTower.Add(ind);
        FieldIndex tmp = ind.Up(direction);
        newTower.Add(tmp);
        ind = tmp.Right(direction);
        //Debug.Log("Looking for 3rd piece forward on "+tmp.ToString());

        if(ind.index != -1 && taken[ind]==true){
            newTower.Add(ind);
            ind = ind.Down(direction);
            //Debug.Log("Looking for 4th piece right on "+tmp.ToString());

            if(ind.index != -1 && taken[ind]==true){
                newTower.Add(ind);
        //				Debug.Log(newTower.ToString());
                buildList.Add(newTower);
            }
        }
    }
Ejemplo n.º 5
0
    public static void FindFiveTower(int direction, FieldIndex ind, Field<bool> taken, ref List<Tower> buildList)
    {
        Tower newTower = new Tower();
        FieldIndex tmp = ind.Up(direction);
        newTower.Add(ind);
        newTower.Add(tmp);
        newTower.type = TowerType.five;
        ind = tmp;
        tmp = ind.Up(direction);

        if(tmp.index != -1 && taken[tmp] == true){
            newTower.Add(tmp);
            ind = tmp;
            tmp = ind.Up(direction);
            if(tmp.index != -1 && taken[tmp] == true){
                newTower.Add(tmp);
                ind = tmp;
                tmp = ind.Up(direction);
                if(tmp.index != -1 && taken[tmp] == true){
                    newTower.Add(tmp);
        //					Debug.Log(newTower.ToString());
                    buildList.Add(newTower);
                }
            }
        }
    }