Beispiel #1
0
 public void TriggerCategory_Spell()
 {
     if (GC.getActionPoints() <= 0)
     {
         return;
     }
     //Do UI stuff
     ShowSpells(true);
     if (!chosenSpell)
     {
         chosenSpell      = true;
         currentItemChild = 0;
         MoveMenuSelector(GameObject.Find("SpellPanel"));
         Debug.Log("Moving ...");
     }
     else if (chosenSpell)
     {
         if (resolveSpell)
         {
             GameObject[] spell_tiles = GameObject.FindGameObjectsWithTag("Tile");
             foreach (GameObject tile in spell_tiles)
             {
                 tileClass tc    = tile.GetComponent <tileClass>();
                 int       calc2 = Math.Abs(SC.getX() - tc.getX()) + Math.Abs(SC.getY() - tc.getY()); // Manhattan distance
                 if (calc2 <= SC.getCurrentSpellAoe())
                 {
                     if (tc.getCurrentCreature() != null)
                     {
                         GetSelectedSpell().trigger(tc.getCurrentCreature().GetComponent <CreatureClass>());
                         Debug.Log("Triggering spell on creature in range: " + tc.getCurrentCreature().GetComponent <CreatureClass>().getName());
                     }
                 }
             }
             Debug.Log("Resolving spell");
             chosenSpell  = false;
             resolveSpell = false;
             SC.setMoveMode(false);
             SC.clearCache();
             //HACKFIX
             //REDACTED resetPointer();
             //currentCategory = GameObject.Find("UI_Playmode_panel").transform.GetChild(0).transform.GetChild(0).gameObject;
             ShowUI_PLAYMODE();
             UpdateUI_PLAYMODE();
             //REDACTED MoveOutCategory();
             GC.actionPointSpent();
             SB.play(SB.SpellBuff);
             SC.AttackCreatureSpell_stockhold();
             //hideSkillBook();
         }
         else if (!resolveSpell)
         {
             SC.setCurrentSpellRange(GetSelectedSpell().getRange());
             SC.setCurrentSpellAoe(GetSelectedSpell().getAoE());
             SC.SelectCreatureOnTile(SC.getX(), SC.getY(), 4);
             SC.setMoveMode(true);
             HideUI_PLAYMODE();
             Debug.Log("setting spell: " + GetSelectedSpell().getSpellName());
             resolveSpell = true;
         }
         //END
     }
 }
Beispiel #2
0
    void EnterAreaMode(int mode)
    {
        int x;
        int y;

        switch (mode)
        {
        case 1:     // MOVE
            int moveLength = currentCreatureSelected.GetComponent <CreatureClass>().getMoveLength();
            x = currentCreatureSelected.GetComponent <CreatureController>().getPosX();
            y = currentCreatureSelected.GetComponent <CreatureController>().getPosY();
            GameObject[] tiles;
            tiles = GameObject.FindGameObjectsWithTag("Tile");
            foreach (GameObject tile in tiles)
            {
                tileClass tc = tile.GetComponent <tileClass>();
                //double calc = Math.Floor(Math.Sqrt(Math.Pow(x-tc.getX(),2) + Math.Pow(y-tc.getY(),2))); //Euclidean distance
                int calc2 = Math.Abs(x - tc.getX()) + Math.Abs(y - tc.getY());     // Manhattan distance
                if (calc2 <= moveLength)
                {
                    if (Math.Abs(tc.GetHeight() - currentCreatureSelected.GetComponent <CreatureController>().getCurrentTile().GetComponent <tileClass>().GetHeight()) > 2 || tc.getCurrentCreature() != null)
                    {
                        continue;
                    }
                    tileReachList.Add(tc.gameObject);
                    //DEBUG
                    GameObject tmp = Instantiate(ok);
                    tmp.transform.SetParent(GameObject.Find("Selector_Cache").transform);
                    tmp.transform.position = tc.transform.position;
                    tmp.GetComponent <SpriteRenderer>().sortingOrder = 400;
                }
            }
            break;

        case 2:     // ATTACK MELEE
            int AtkLength = 1;
            x = currentCreatureSelected.GetComponent <CreatureController>().getPosX();
            y = currentCreatureSelected.GetComponent <CreatureController>().getPosY();
            GameObject[] tiles_atk;
            tiles_atk = GameObject.FindGameObjectsWithTag("Tile");
            foreach (GameObject tile in tiles_atk)
            {
                tileClass tc = tile.GetComponent <tileClass>();
                //double calc = Math.Floor(Math.Sqrt(Math.Pow(x-tc.getX(),2) + Math.Pow(y-tc.getY(),2))); //Euclidean distance
                int calc2 = Math.Abs(x - tc.getX()) + Math.Abs(y - tc.getY());     // Manhattan distance
                if (calc2 <= AtkLength)
                {
                    tileReachList.Add(tc.gameObject);
                    //DEBUG
                    GameObject tmp = Instantiate(ok_atk);
                    tmp.transform.SetParent(GameObject.Find("Selector_Cache").transform);
                    tmp.transform.position = tc.transform.position;
                    tmp.GetComponent <SpriteRenderer>().sortingOrder = 400;
                }
            }
            break;

        case 3:     // ATTACK RANGED
            int BowLength = currentCreatureSelected.GetComponent <CreatureClass>().getMainHandBow().getRange();
            x = currentCreatureSelected.GetComponent <CreatureController>().getPosX();
            y = currentCreatureSelected.GetComponent <CreatureController>().getPosY();
            GameObject[] tiles_rng = GameObject.FindGameObjectsWithTag("Tile");
            foreach (GameObject tile in tiles_rng)
            {
                tileClass tc = tile.GetComponent <tileClass>();
                //double calc = Math.Floor(Math.Sqrt(Math.Pow(x-tc.getX(),2) + Math.Pow(y-tc.getY(),2))); //Euclidean distance
                int calc2 = Math.Abs(x - tc.getX()) + Math.Abs(y - tc.getY());     // Manhattan distance
                if (calc2 <= BowLength)
                {
                    tileReachList.Add(tc.gameObject);
                    //DEBUG
                    GameObject tmp = Instantiate(ok_atk);
                    tmp.transform.SetParent(GameObject.Find("Selector_Cache").transform);
                    tmp.transform.position = tc.transform.position;
                    tmp.GetComponent <SpriteRenderer>().sortingOrder = 400;
                }
            }
            break;

        case 4:     // SPELL
            int spellLength = getCurrentSpellRange();
            int spellAOE    = getCurrentSpellAoe();
            x = currentCreatureSelected.GetComponent <CreatureController>().getPosX();
            y = currentCreatureSelected.GetComponent <CreatureController>().getPosY();
            GameObject[] tiles_spell = GameObject.FindGameObjectsWithTag("Tile");
            foreach (GameObject tile in tiles_spell)
            {
                tileClass tc = tile.GetComponent <tileClass>();
                //double calc = Math.Floor(Math.Sqrt(Math.Pow(x-tc.getX(),2) + Math.Pow(y-tc.getY(),2))); //Euclidean distance
                int calc2 = Math.Abs(x - tc.getX()) + Math.Abs(y - tc.getY());     // Manhattan distance
                if (calc2 <= spellLength)
                {
                    tileReachList.Add(tc.gameObject);
                    //DEBUG
                    GameObject tmp = Instantiate(ok);
                    tmp.transform.SetParent(GameObject.Find("Selector_Cache").transform);
                    tmp.transform.position = tc.transform.position;
                    tmp.GetComponent <SpriteRenderer>().sortingOrder = 400;
                }

                if (calc2 <= spellAOE)
                {
                    GameObject tmp = Instantiate(ok_atk);
                    tmp.transform.SetParent(GameObject.Find("Selector_Cache_Main").transform);
                    tmp.transform.position = tc.transform.position;
                    tmp.GetComponent <SpriteRenderer>().sortingOrder = 400;
                }
            }
            break;
        }
    }
Beispiel #3
0
    public CreatureClass getCreatureHover()
    {
        tileClass tc = GameObject.Find(getX().ToString() + "," + getY().ToString()).GetComponent <tileClass>();

        return(tc.getCurrentCreature().GetComponent <CreatureClass>());
    }
Beispiel #4
0
        //Creates a size X size grid of tiles
        /// <summary>
        /// Initalizes the tile board onto panel_tile_holder
        /// </summary>
        /// <param name="size">The number of tiles on the game board. size x size </param>
        private void init_board()
        {
            board = new tileClass[n, n];

            for (int i = 0; i < n; ++i)
            {
                for (int j = 0; j < n; ++j)    // This is where I print the gameboard into the panel
                {
                    //715x790 - current size of form 6-12-14
                    board[i, j] = new tileClass(i, j);
                    board[i, j].tile.Size = new System.Drawing.Size(xTileDim, yTileDim);
                    board[i, j].tile.BackColor = Color.Transparent;

                    board[i, j].tile.Location = new System.Drawing.Point(i * (xTileDim - 3) + 60, j * (yTileDim + 5) + 5);

                    board[i, j].tileImage();

                    panel_tile_holder.Controls.Add(board[i, j].tile);
                }
            }
        }