コード例 #1
0
 protected void Hit(HealBox box)
 {
     health += box.Take();
     if (health > 100)
     {
         health = 100;
     }
 }
コード例 #2
0
 void CheckForItem()
 {
     currentTile = GetCurrentTile();
     ShowCurrentTile();
     currentTile.GetItemTiles();
     foreach (Tile tile in currentTile.itemTiles)
     {
         healBox         = tile.GetItem();
         tile.attackable = true;
     }
 }
コード例 #3
0
 public void UseItem()
 {
     GetComponent <CharacterStats>().Heal(healBox.healAmount);
     healBox.SetUsedMaterial();
     healBox.PlayParticles();
     healBox.used = true;
     //Destroy(healBox.gameObject,1.0f);
     foreach (Tile tile in currentTile.adjacentTiles)
     {
         tile.attackable = false;
     }
     healBox = null;
 }
コード例 #4
0
        public void createListGameObject()
        {
            List <int> positionOfSheet = new List <int>();

            for (int i = 0; i < amountOfTempo; i++)
            {
                positionOfSheet.Add(i);
            }

            for (int i = 0; i < amountOfObjects; i++)
            {
                int positionIndex = random.Next(0, positionOfSheet.Count);
                int position      = positionOfSheet[positionIndex] * distanceOfObjectes;
                positionOfSheet.RemoveAt(positionIndex);


                switch (random.Next(0, 5))
                {
                case 0:
                    gameObjects.Add(new Obstacle(ObstracleMinusHp, ObstracleMinusScore, position));
                    break;

                case 1:
                    gameObjects.Add(new HealBox(healboxHp, position));
                    break;

                case 2:
                    gameObjects.Add(new Obstacle(ObstracleMinusHp, ObstracleMinusScore, position));
                    break;

                default:
                    gameObjects.Add(new Platform(platformScore, position));
                    break;
                }
            }

            gameObjects.Sort();

            for (int i = 0; i < gameObjects.Count; i++)
            {
                if (i + 1 != gameObjects.Count)
                {
                    if (gameObjects[i] is Obstacle && gameObjects[i + 1] is Obstacle)
                    {
                        int doubleObstacle = gameObjects[i + 1].position;
                        if (i % 3 == 0)
                        {
                            gameObjects[i + 1] = new HealBox(healboxHp, doubleObstacle);
                        }
                        else
                        {
                            gameObjects[i + 1] = new Platform(platformScore, doubleObstacle);
                        }
                    }
                }
            }

            for (int i = 0; i < gameObjects.Count; i++)
            {
                if (i + 1 < gameObjects.Count)
                {
                    gameObjects[i].nextGameObject = gameObjects[i + 1];
                }
            }
        }
コード例 #5
0
        public void createGameObjects()                    // 創造gameobjects list
        {
            List <int> positionOfSheet = new List <int>(); // 將位置先儲存起來

            for (int i = 0; i < amountOfTempo; i++)
            {
                positionOfSheet.Add(i);
            }

            for (int i = 0; i < amountOfObjects; i++)
            {
                int positionIndex = random.Next(0, positionOfSheet.Count);
                int position      = positionOfSheet[positionIndex] * distanceOfObjectes;
                positionOfSheet.RemoveAt(positionIndex);


                // 生成GameObject用隨機的方式
                // 要再改成有一定規則
                switch (random.Next(0, 5))
                {
                case 0:
                    gameObjects.Add(new Obstacle(this, obstracleMinusHp, obstracleMinusScore, position));
                    break;

                case 1:
                    gameObjects.Add(new HealBox(this, healboxHp, position));
                    break;

                case 2:
                    gameObjects.Add(new Obstacle(this, obstracleMinusHp, obstracleMinusScore, position));
                    break;

                default:
                    gameObjects.Add(new Platform(this, platformScore, position));
                    break;
                }
            }

            gameObjects.Sort();


            for (int i = 0; i < gameObjects.Count; i++)
            {
                if (i + 1 != gameObjects.Count)
                {
                    if (gameObjects[i] is Obstacle && gameObjects[i + 1] is Obstacle)
                    {
                        int doubleObstacle = gameObjects[i + 1].x;
                        if (i % 3 == 0)
                        {
                            gameObjects[i + 1] = new HealBox(this, healboxHp, doubleObstacle);
                        }
                        else
                        {
                            gameObjects[i + 1] = new Platform(this, platformScore, doubleObstacle);
                        }
                    }
                }
            }


            for (int i = 0; i < gameObjects.Count; i++)
            {
                if (i + 1 < gameObjects.Count)
                {
                    gameObjects[i].nextGameObject = gameObjects[i + 1];
                }
            }
        }