Ejemplo n.º 1
0
 /*
  * This function calls the function that
  * will delete the this object from the
  * game manager and the also deletes the
  * this objects clone.
  */
 public void death()
 {
     if (!this.name.EndsWith("(Clone)"))
     {
         CreateClone.DeleteClones(this.tag, this.name);
         GetComponentInParent <gameManager> ().deleteEntity(this.gameObject);
         this.gameObject.SetActive(false);
         Destroy(this.gameObject);
     }
 }
Ejemplo n.º 2
0
    public void MakeTree()
    {
        CreateClone.SecondryUpdate();
        root = new GameStateNode(null, CreateClone.getStates(), -1);

        /*foreach (playerStateNode p in root.entities.players)
         *      Debug.Log (p.pos + ", " + p.health + ", " + p.damage);
         * foreach (playerStateNode p in root.entities.enemies)
         *      Debug.Log (p.pos + ", " + p.health + ", " + p.damage);*/
        CreateChildren(root, depth);
    }
Ejemplo n.º 3
0
    public void CreateChildren(GameStateNode state, int depth)
    {
        if (depth == 0)
        {
            return;
        }

        List <playerStateNode> attackers;
        List <playerStateNode> defenders;

        state.children = new List <GameStateNode> ();

        CreateClone.updateHealth(state.entities, "Players");
        CreateClone.updateHealth(state.entities, "Enemies");

        if (state.enemysTurn)
        {
            attackers = state.entities.enemies;
            defenders = state.entities.players;
        }
        else
        {
            defenders = state.entities.enemies;
            attackers = state.entities.players;
        }


        for (int i = 0; i < attackers.Count; ++i)
        {
            for (int j = 0; j < defenders.Count; ++j)
            {
                List <position> possibleMoves;
                string          type = CreateClone.EntityType(!state.enemysTurn, i);
                if (type == "attacker")
                {
                    possibleMoves = attacker(CreateClone.entityRange(!state.enemysTurn, i), defenders[j].pos);
                }
                else if (type == "healler")
                {
                    possibleMoves = healler(defenders[j].pos);
                }
                else                  //if(type == "diagnoller"){
                {
                    possibleMoves = diagnoller(defenders[j].pos);
                }
                foreach (position pos in possibleMoves)
                {
                    //Debug.Log(pos);
                    if (!CanGoTo(pos, ref state.entities))
                    {
                        continue;
                    }
                    CreateClone.UpdatePos(!state.enemysTurn, i, pos);
                    CreateClone.attack(!state.enemysTurn, i);
                    state.children.Add(new GameStateNode(state, CreateClone.getStates(), i));
                    CreateChildren(state.children[state.children.Count - 1], depth - 1);
                    CreateClone.updateHealth(state.entities, "Players");
                    CreateClone.updateHealth(state.entities, "Enemies");
                }
            }
        }
    }