コード例 #1
0
 public void AddTile(GameTile gameTile)
 {
     if (!map.ContainsKey(gameTile.GetCoordinates()))
     {
         map.Add(gameTile.GetCoordinates(), gameTile);
     }
     else
     {
         Debug.LogError("Error: Duplicate Tile Placement at: " + gameTile.GetCoordinates());
     }
 }
コード例 #2
0
    public override void SetCharacter(Character character)
    {
        Character oldCharacter = this.character;

        this.character = character;
        if (!this.sprung && oldCharacter == null)
        {
            Dialog dialog = this.GetComponent <Dialog>();
            if (dialog != null && this.character is Player)
            {
                dialog.DisplayDialogMessage();
            }

            bool trapActive = false;
            switch (trapDependency)
            {
            case TrapDependency.Health:
                if (this.character.GetHealth() < minDependency || this.character.GetHealth() > maxDependency)
                {
                    trapActive = true;
                }
                break;

            case TrapDependency.Level:
                if (this.character.GetLevel() < minDependency || this.character.GetLevel() > maxDependency)
                {
                    trapActive = true;
                }
                break;

            case TrapDependency.Gold:
                if (this.character.GetGold() < minDependency || this.character.GetGold() > maxDependency)
                {
                    trapActive = true;
                }
                break;

            default:
                trapActive = true;
                break;
            }

            if (trapActive)
            {
                if (achievement != "" && this.character is Player)
                {
                    if (achievement == "Game Complete")
                    {
                        switch (curGm.difficulty)
                        {
                        case GameManager.Difficulty.Extreme:
                            ((Player)character).completeAchievement("Game Complete Extreme");
                            goto case GameManager.Difficulty.Hard;

                        case GameManager.Difficulty.Hard:
                            ((Player)character).completeAchievement("Game Complete Hard");
                            goto case GameManager.Difficulty.Normal;

                        case GameManager.Difficulty.Normal:
                            ((Player)character).completeAchievement("Game Complete Normal");
                            goto case GameManager.Difficulty.Easy;

                        case GameManager.Difficulty.Easy:
                            ((Player)character).completeAchievement("Game Complete Easy");
                            break;

                        default:
                            break;
                        }
                    }
                    else
                    {
                        ((Player)character).completeAchievement(achievement);
                    }
                }

                if (damage > 0)
                {
                    character.ReceiveDamage(damage);
                }

                if (!resetting)
                {
                    this.sprung = true;
                }

                if (newLevel != "" && this.character is Player)
                {
                    curGm.GetSaveManager().SaveData();
                    PlayerPrefs.SetString("levelname", newLevel);
                    Debug.Log(newLevel);
                    curGm.loadNewLevel(newLevel);
                }

                if (spawnLocation != null)
                {
                    if (spawnLocation.GetCharacter() == null && spawnLocation.IsWalkable())
                    {
                        switch (curGm.difficulty)
                        {
                        case GameManager.Difficulty.Easy:
                            Instantiate(whatToSpawnEasy, spawnLocation.GetCoordinates(), Quaternion.identity);
                            break;

                        case GameManager.Difficulty.Hard:
                            Instantiate(whatToSpawnHard, spawnLocation.GetCoordinates(), Quaternion.identity);
                            break;

                        case GameManager.Difficulty.Extreme:
                            Instantiate(whatToSpawnExtreme, spawnLocation.GetCoordinates(), Quaternion.identity);
                            break;

                        default:
                            Instantiate(whatToSpawnNormal, spawnLocation.GetCoordinates(), Quaternion.identity);
                            break;
                        }
                    }
                }

                if (achievementShowcase != "" && this.character is Player)
                {
                    ((Player)character).displayAchievement(achievementShowcase);
                }

                if (test)
                {
                    //These are test functions to run them easily somewhere, just
                    //make sure test is false for real game tiles
                    //also try to remember to comment out tests as a double safety
                    //((Player)character).wipeAchievements();
                }
            }
        }
        base.SetCharacter(character);
    }