コード例 #1
0
        public void SpellWalkToAway(Tile target, Tile caster, SpellCreator.SpellAttribute attribute)
        {
            Side side;

            side = WhichSide(caster, target, attribute.moveTowards);

            GridController.Directions tempDir = GridController.Directions.none;

            switch (side)
            {
            case Side.up:
                tempDir = GridController.Directions.up;
                break;

            case Side.down:
                tempDir = GridController.Directions.down;
                break;

            case Side.left:
                tempDir = GridController.Directions.left;
                break;

            case Side.right:
                tempDir = GridController.Directions.right;
                break;
            }
            Tile korjaus = caster;

            // for luuppi käydään läpi vetojen verran
            for (int i = 0; i < attribute.movemenPoints; i++)
            {
                Tile temp = gridController.GetTileInDirection(gridController.GetTile(korjaus.locX, korjaus.locZ), 1, tempDir);
                if (temp.myType == Tile.BlockType.BaseBlock && temp.CharCurrentlyOnTile == false)
                {
                    PullPushMove(korjaus, temp, PlayerMovement.MovementMethod.Teleport);
                    korjaus = temp;
                }
                else
                {
                    Debug.Log("wall hit");
                    break;
                }
            }
        }
コード例 #2
0
        // V V V Pull/Push methods motor
        public void PullPushMotor(Side tempSide, SpellCreator.SpellAttribute attribute, Tile start, int rajaaja)
        {
            // korjaus on temp tile
            Tile korjaus = start;

            //korjaus.locX = start.locX;
            //korjaus.locZ = start.locZ;

            // tempdir ja helpdir ovat tilapäisiä suuntia joilla ohjataan tarkistuksia
            GridController.Directions tempDir = GridController.Directions.none;
            GridController.Directions helpDir = GridController.Directions.none;

            // inline määrittää onko veto lineaarinen [+] vai diagonaalinen [X]
            bool inline = true;

            switch (tempSide)
            {
            case Side.up:
                tempDir = GridController.Directions.down;
                break;

            case Side.down:
                tempDir = GridController.Directions.up;
                break;

            case Side.left:
                tempDir = GridController.Directions.right;
                break;

            case Side.right:
                tempDir = GridController.Directions.left;
                break;

            case Side.upLeft:
                tempDir = GridController.Directions.down;
                helpDir = GridController.Directions.right;
                inline  = false;
                break;

            case Side.upRight:
                tempDir = GridController.Directions.down;
                helpDir = GridController.Directions.left;
                inline  = false;
                break;

            case Side.downLeft:
                tempDir = GridController.Directions.up;
                helpDir = GridController.Directions.right;
                inline  = false;
                break;

            case Side.downRight:
                tempDir = GridController.Directions.up;
                helpDir = GridController.Directions.left;
                inline  = false;
                break;
            }
            // kun veto on lineaarinen
            if (inline == true)
            {
                if (rajaaja == 0 || rajaaja == 2)
                {
                    // for luuppi käydään läpi vetojen verran
                    for (int i = 0; i < attribute.spellPullPush; i++)
                    {
                        Tile temp = gridController.GetTileInDirection(gridController.GetTile(korjaus.locX, korjaus.locZ), 1, tempDir);
                        if (temp.myType == Tile.BlockType.BaseBlock && temp.CharCurrentlyOnTile == false)
                        {
                            PullPushMove(korjaus, temp, PlayerMovement.MovementMethod.Teleport);
                            korjaus = temp;
                        }
                        else
                        {
                            Debug.Log("wall hit");
                            break;
                        }
                    }
                }
            }
            else
            {
                if (rajaaja == 0 || rajaaja == 1)
                {
                    for (int i = 0; i < attribute.spellPullPush; i++)
                    {
                        Tile temp1 = gridController.GetTileInDirection(gridController.GetTile(korjaus.locX, korjaus.locZ), 1, tempDir);
                        Tile temp2 = gridController.GetTileInDirection(gridController.GetTile(korjaus.locX, korjaus.locZ), 1, helpDir);
                        Tile temp3 = gridController.GetTileInDirection(gridController.GetTile(temp1.locX, temp1.locZ), 1, helpDir);
                        if (temp1.myType == Tile.BlockType.BaseBlock && temp1.CharCurrentlyOnTile == false && temp2.myType == Tile.BlockType.BaseBlock && temp2.CharCurrentlyOnTile == false && temp3.myType == Tile.BlockType.BaseBlock && temp3.CharCurrentlyOnTile == false)
                        {
                            PullPushMove(korjaus, temp3, PlayerMovement.MovementMethod.Teleport);
                            korjaus = temp3;
                            //item.locX = temp3.locX;
                            //item.locZ = temp3.locZ;
                        }
                        else
                        {
                            break;
                        }
                    }
                }
            }
            inline = true;
        }