Beispiel #1
0
    public void Update()
    {
        if (Constant.LastSceneLoaded != "StatsMenu")
        {
            switch (MenuSelected)
            {
            case 0:
                Menu.update();
                break;

            case 1:
                MenuScroll.update();
                break;

            case 2:
                Menu2.update();
                break;

            default:
                break;
            }
        }
        else
        {
            if (ProxyInput.GetInstance().BUp())
            {
                GameObject.Find("StartMenu").transform.FindChild("Canvas").gameObject.GetComponent <Menus>().disable = false;
                Destroy(GameObject.Find("StatsMenu"));
                Constant.LastSceneLoaded = "StartMenu";
            }
        }
    }
Beispiel #2
0
    /// <summary>
    /// Funcion para actualizar el estado del selector
    /// </summary>
    public override void update()
    {
        if (ProxyInput.GetInstance().AUp())
        {
            Options[selected].GetComponent <MenuOption>().OnSelect();
        }
        else if (ProxyInput.GetInstance().BUp())
        {
            delay = 0;
            Options[selected].GetComponent <MenuOption>().UnSelect();

            return;
        }
        else if (ProxyInput.GetInstance().DownUp())
        {
            if (selected == Options.Count - 1)
            {
                selected = 0;
                Options[selected].GetComponent <MenuOption>().On(Options[selected].GetComponent <Text>().text);
            }
            else
            {
                selected++;
                Options[selected].GetComponent <MenuOption>().On(Options[selected].GetComponent <Text>().text);
            }
            Arrow.transform.position = new Vector3(Arrow.transform.position.x, Options[selected].gameObject.transform.position.y);
        }
        else if (ProxyInput.GetInstance().UpUp())
        {
            if (selected == 0)
            {
                selected = Options.Count - 1;
                Options[selected].GetComponent <MenuOption>().On(Options[selected].GetComponent <Text>().text);
            }
            else
            {
                selected--;
                Options[selected].GetComponent <MenuOption>().On(Options[selected].GetComponent <Text>().text);
            }
            Arrow.transform.position = new Vector3(Arrow.transform.position.x, Options[selected].gameObject.transform.position.y);
        }

        delay = 0;
    }
Beispiel #3
0
 void Update()
 {
     if (!Constant.start)
     {
         MoveDirection(ProxyInput.GetInstance().Down(), "down", 0);
         MoveDirection(ProxyInput.GetInstance().Left(), "left", 0.34f);
         MoveDirection(ProxyInput.GetInstance().Up(), "up", 0.67f);
         MoveDirection(ProxyInput.GetInstance().Right(), "right", 1);
         PlayerMove();
     }
     if (ProxyInput.GetInstance().Pause() && !Constant.start)
     {
         Constant.ActiveMap = GameObject.Find("Map");
         Constant.ActiveMap.SetActive(false);
         Constant.LastSceneLoaded = "StartMenu";
         Application.LoadLevelAdditive("StartMenu");
         Constant.start = true;
     }
 }
Beispiel #4
0
    private bool PlayerMove()
    {
        float horizontal = 0;
        float vertical   = 0;

        //Get input from the input manager, round it to an integer and store in horizontal to set x axis move direction
        horizontal = ProxyInput.GetInstance().GetHorizontal();
        vertical   = ProxyInput.GetInstance().GetVertical();

        if (horizontal != 0 || vertical != 0)
        {
            Debug.Log(horizontal.ToString() + "," + vertical.ToString());
        }

        if (Move(horizontal, vertical))
        {
            return(false);
        }

        return(true);
    }
Beispiel #5
0
    void Update()
    {
        if (!working)
        {
            int damage = 0;
            if (Enemies.Count <= 0 && BattleState != BattleStateMachine.LVLUP && BattleState != BattleStateMachine.ENDBATTLE)
            {
                BattleState = BattleStateMachine.WIN;
            }
            if (Player.Data.HP <= 0 && BattleState != BattleStateMachine.ENDBATTLE)
            {
                BattleState = BattleStateMachine.LOSE;
            }
            switch (BattleState)
            {
            case BattleStateMachine.PLAYERTURN:
                if (SELECTIONMODE)
                {
                    if (ProxyInput.GetInstance().Up())
                    {
                        if (enemySelect + 1 >= Enemies.Count)
                        {
                            break;
                        }
                        enemySelect++;
                        PositionSelector(enemySelect);
                    }
                    else if (ProxyInput.GetInstance().Down())
                    {
                        if (enemySelect - 1 < 0)
                        {
                            break;
                        }
                        enemySelect--;
                        PositionSelector(enemySelect);
                    }
                    else if (ProxyInput.GetInstance().A() || (UsableToUse != null && UsableToUse.AreaOfEffect == Constant.AOE.Self))
                    {
                        switch (ActionSelected)
                        {
                        case Actions.Attack:

                            AbstractActor attacker = Player.Data;
                            AbstractActor defender = Enemies[enemySelect].GetComponent <Enemy>().BattleEnemy.Data;
                            damage   = NormalFight(ref attacker, ref defender, 0);
                            Message += "You have Attack! " + defender.ActorName + " has recive " + damage + " damage.";

                            break;

                        case Actions.Ability:

                            AbstractActor attacker2 = Player.Data;
                            AbstractActor defender2 = Enemies[enemySelect].GetComponent <Enemy>().BattleEnemy.Data;
                            damage   = AbilityFight(ref attacker2, ref defender2, AbilityToUse);
                            Message += "You have use " + AbilityToUse.Ability + "! " + defender2.ActorName + " has recive " + damage + " damage.";

                            break;

                        case Actions.Usable:
                            AbstractActor actor = null;
                            if (UsableToUse.AreaOfEffect == Constant.AOE.OneEnemy)
                            {
                                actor = Enemies[enemySelect].GetComponent <Enemy>().BattleEnemy.Data;
                            }
                            else
                            {
                                actor = Player.Data;
                            }
                            Message = UsableToUse.ItemName + " has been use on " + actor.ActorName + "! ";
                            damage  = ItemFigth(ref actor);
                            break;

                        default:
                            break;
                        }

                        StartCoroutine(ShowMessage());
                    }
                    else if (ProxyInput.GetInstance().B())
                    {
                        deactivateSelector();
                        BattleMenu.SetActive(true);
                        SELECTIONMODE = false;
                    }
                }
                //Player.RemoveOnTurnState();
                break;

            case BattleStateMachine.ENEMYTURN:

                AbstractAbility ability = Enemies[enemySelect].GetComponent <Enemy>().AttackSelected();
                if (ability == null)
                {
                    AbstractActor defender = Player.Data;
                    AbstractActor attacker = Enemies[enemySelect].GetComponent <Enemy>().BattleEnemy.Data;
                    damage   = NormalFight(ref attacker, ref defender, 0);
                    Message += attacker.ActorName + " " + enemySelect + 1 + " has attack! " + damage.ToString() + " Damage dealt ";
                }
                else
                {
                    AbstractActor defender = Player.Data;
                    AbstractActor attacker = Enemies[enemySelect].GetComponent <Enemy>().BattleEnemy.Data;
                    damage   = AbilityFight(ref attacker, ref defender, ability);
                    Message += attacker.ActorName + " " + enemySelect + 1 + " has use " + ability.Ability + "! " + damage.ToString() + " Damage dealt ";
                }

                StartCoroutine(ShowMessage());
                break;

            case BattleStateMachine.WIN:
                string sitems = "";
                foreach (var i in ItemsDrop)
                {
                    sitems += ", " + i.ItemName;
                    Player.Items.InsertUsable(i);
                }
                lvlup = Player.ApplyXp(GainXp);

                Message = "You have earn " + GainXp + " XP, " + sitems;
                StartCoroutine(ShowMessage());
                break;

            case BattleStateMachine.LOSE:
                Message = "You have lost the battle!";
                StartCoroutine(ShowMessage());
                break;

            case BattleStateMachine.LVLUP:
                Message = "You have Reach Level " + Player.Data.Level;
                showStats();
                StartCoroutine(ShowMessage());
                break;

            case BattleStateMachine.ENDBATTLE:
                Destroy(GameObject.Find("BattleMap"));
                Destroy(GameObject.Find("BattleMenu"));
                Constant.ActiveMap.SetActive(true);
                Constant.Control.SetActive(true);
                Player.transform.position = Constant.playerPos;
                break;
            }
        }
    }
Beispiel #6
0
    void OnCollisionStay2D(Collision2D coll)
    {
        Pickup pickup = coll.gameObject.GetComponent <Pickup>();

        if (pickup != null)
        {
            if (ProxyInput.GetInstance().A())
            {
                if (pickup.Sound != null)
                {
                    Audio audio = new Audio(pickup.name);
                    audio.CreateAudioSource(pickup.Sound);
                    audio.Source.Play();
                    Destroy(audio.gameobject, pickup.Sound.length + 0.5f);
                }

                if (pickup.ItemArmor.ItemName != "")
                {
                    AbstractArmor armor = new AbstractArmor();
                    armor = pickup.ItemArmor;
                    this.Items.InsertArmor(armor);
                }
                if (pickup.ItemWeapon.ItemName != "")
                {
                    this.Items.InsertWeapon(pickup.ItemWeapon);
                }
                if (pickup.ItemUsable.ItemName != "")
                {
                    this.Items.InsertUsable(pickup.ItemUsable);
                }
                Destroy(coll.gameObject);
            }
        }

        var obstacle = coll.gameObject.GetComponent <Obstacle>();

        if (obstacle != null)
        {
            if (ProxyInput.GetInstance().A())
            {
                if (obstacle.Sound != null)
                {
                    Audio audio = new Audio(name);
                    audio.CreateAudioSource(obstacle.Sound);
                    audio.Source.Play();
                    Destroy(audio.gameobject, obstacle.Sound.length + 0.5f);
                }

                if (obstacle.Type == Constant.ObstacleType.Switchable)
                {
                    obstacle.Switched = !obstacle.Switched;
                }
                else if (obstacle.Type == Constant.ObstacleType.Destroyable)
                {
                    obstacle.hp -= Data.TotalDamage();

                    if (obstacle.hp <= 0)
                    {
                        Destroy(obstacle.gameObject);
                    }
                }
            }
        }
    }
Beispiel #7
0
    /// <summary>
    /// Funciona para navegar el menu
    /// </summary>
    public override void update()
    {
        if (!Arrow.activeSelf)
        {
            return;
        }
        if (ProxyInput.GetInstance().BUp())
        {
            Options[selected].Key.GetComponent <MenuOption>().UnSelect();
            return;
        }
        else if (ProxyInput.GetInstance().AUp())
        {
            Options[selected].Key.GetComponent <MenuOption>().OnSelect();
        }


        else if (ProxyInput.GetInstance().DownUp())
        {
            if (selected + ScrollCant < ElementCant - 1)
            {
                NextArrow.SetActive(true);
            }
            if (selected == MaxItem - 1 && (selected + ScrollCant) < (ElementCant - 1))
            {
                //Options[selected].GetComponent<MenuOption>().Off(Options[selected].GetComponent<Text>().text);
                ScrollCant++;
                NewListNext();
                if (Items != null)
                {
                    Options[selected].Key.GetComponent <MenuOption>().On(Items[selected + ScrollCant].First);
                }
                else
                {
                    Options[selected].Key.GetComponent <MenuOption>().On(Ability[selected + ScrollCant]);
                }
            }
            else if (selected < Options.Count - 1)
            {
                //Options[selected].GetComponent<MenuOption>().Off(Options[selected].GetComponent<Text>().text);
                selected++;
                if (Items != null)
                {
                    Options[selected].Key.GetComponent <MenuOption>().On(Items[selected + ScrollCant].First);
                }
                else
                {
                    Options[selected].Key.GetComponent <MenuOption>().On(Ability[selected + ScrollCant]);
                }
            }
            else
            {
                NextArrow.SetActive(false);
            }
            Arrow.transform.position = new Vector3(Arrow.transform.position.x, Options[selected].Key.gameObject.transform.position.y);
        }
        else if (ProxyInput.GetInstance().UpUp())
        {
            if (ScrollCant > 0)
            {
                PrevArrow.SetActive(true);
            }
            if (ScrollCant > 0 && selected == 0)
            {
                //Options[selected].GetComponent<MenuOption>().Off(Options[selected].GetComponent<Text>().text);
                ScrollCant--;
                NewListPrev();
                if (Items != null)
                {
                    Options[selected].Key.GetComponent <MenuOption>().On(Items[selected + ScrollCant].First);
                }
                else
                {
                    Options[selected].Key.GetComponent <MenuOption>().On(Ability[selected + ScrollCant]);
                }
            }
            else if (selected > 0)
            {
                //Options[selected].GetComponent<MenuOption>().Off(Options[selected].GetComponent<Text>().text);
                selected--;
                if (Items != null)
                {
                    Options[selected].Key.GetComponent <MenuOption>().On(Items[selected + ScrollCant].First);
                }
                else
                {
                    Options[selected].Key.GetComponent <MenuOption>().On(Ability[selected + ScrollCant]);
                }
            }
            Arrow.transform.position = new Vector3(Arrow.transform.position.x, Options[selected].Value.gameObject.transform.position.y);
        }

        delay = 0;
    }