Example #1
0
    public static void SpawnFollower(Character character, Vector3 followOffset)
    {
        Transform       followerTransform = UnityEngine.Object.Instantiate(GameAssets.i.pfFollowerOvermap, character.position, Quaternion.identity);
        FollowerOvermap followerOvermap   = followerTransform.GetComponent <FollowerOvermap>();

        followerOvermap.Setup(character, instance.playerOvermap, followOffset);
        instance.followerList.Add(followerOvermap);
    }
 private void Awake()
 {
     instance          = this;
     playerBase        = gameObject.GetComponent <Player_Base>();
     material          = transform.Find("Body").GetComponent <MeshRenderer>().material;
     materialTintColor = new Color(1, 0, 0, 0);
     SetStateNormal();
 }
    private void HandleInteract()
    {
        if (((int)GameData.state) < ((int)GameData.State.DefeatedTank))
        {
            if (!spawnedTankInteractKey)
            {
                Character tankCharacter = GameData.GetCharacter(Character.Type.Tank);
                if (Vector3.Distance(GetPosition(), tankCharacter.position) < 12f)
                {
                    spawnedTankInteractKey = true;
                    Instantiate(GameAssets.i.pfKey, tankCharacter.position + new Vector3(0, 15), Quaternion.identity);
                }
            }
        }

        if (Input.GetKeyDown(KeyCode.Space))
        {
            NPCOvermap npcOvermap = OvermapHandler.GetInstance().GetClosestNPC(GetPosition(), 12f);
            if (npcOvermap != null)
            {
                switch (npcOvermap.GetCharacter().type)
                {
                case Character.Type.Tank:
                    // Tank is only a NPC before he joins
                    Cutscenes.Play_Tank_BeforeJoin();
                    break;

                case Character.Type.Healer:
                    // Healer is only a NPC before he joins
                    //Cutscenes.Play_Healer_BeforeJoin();
                    break;

                case Character.Type.PlayerDoppelganger:
                    if (GameData.state == GameData.State.GoingToAskDoppelGanger)
                    {
                        Cutscenes.Play_DoppelGanger();
                    }
                    break;

                case Character.Type.Shop:
                    Cutscenes.Play_Shop(npcOvermap.GetCharacter());
                    break;
                }
            }
            else
            {
                // No NPC in range
                // Consume Health Potion
                if (GameData.TrySpendHealthPotion())
                {
                    // Heal all Team members
                    int healAmount = 40;
                    Heal(healAmount);
                    FollowerOvermap tankOvermap = OvermapHandler.GetInstance().GetFollower(GameData.GetCharacter(Character.Type.Tank));
                    if (tankOvermap != null)
                    {
                        tankOvermap.Heal(healAmount);
                    }
                    FollowerOvermap healerOvermap = OvermapHandler.GetInstance().GetFollower(GameData.GetCharacter(Character.Type.Healer));
                    if (healerOvermap != null)
                    {
                        healerOvermap.Heal(healAmount);
                    }
                }
            }

            /*
             * if (OvermapHandler.GetInstance().TryPlayerInteract()) {
             *  Dialogue dialogue = Dialogue.GetInstance();
             *  dialogue.SetDialogueActions(new List<Action>() {
             *      () => {
             *          dialogue.Show();
             *          dialogue.ShowLeftCharacter(GameAssets.i.s_PlayerDialogueSprite);
             *          dialogue.ShowLeftText("Hello there General Kenobi");
             *          dialogue.ShowRightCharacter(GameAssets.i.s_PlayerDialogueSprite);
             *          dialogue.FadeRightCharacter();
             *      },
             *      () => {
             *          dialogue.ShowRightActiveTalkerHideLeft("Yes yes hello there...");
             *      },
             *      () => {
             *          dialogue.ShowRightText("What brings you here?");
             *      },
             *      () => {
             *          dialogue.ShowLeftActiveTalkerHideRight("Oh I don't know");
             *      },
             *      () => {
             *          dialogue.ShowLeftText("Lets battle!");
             *      },
             *      () => {
             *          Loader.Load(Loader.Scene.BattleScene);
             *      },
             *  });
             *  dialogue.PlayNextAction();
             *  ///
             *  dialogue.SetDialogueActions(new List<Action>() {
             *      () => {
             *          dialogue.Show();
             *          dialogue.ShowLeftCharacter(GameAssets.i.s_PlayerDialogueSprite, false);
             *          dialogue.ShowRightCharacter(GameAssets.i.s_PlayerDialogueSprite, true);
             *          dialogue.ShowDialogueOptions(new List<Dialogue.DialogueOption> {
             *              new Dialogue.DialogueOption(Dialogue.DialogueOption.Option._1, "Hello there!", () => {
             *                  dialogue.ClearDialogueOptions();
             *                  dialogue.ShowRightActiveTalkerHideLeft("Yes yes hello there...");
             *              }),
             *              new Dialogue.DialogueOption(Dialogue.DialogueOption.Option._2, "General Kenobi!", () => {
             *                  dialogue.ClearDialogueOptions();
             *                  dialogue.ShowRightActiveTalkerHideLeft("Yes yes hello there...");
             *              }),
             *          });
             *      },
             *  }, true);
             * }
             */
        }
    }