Inheritance: MonoBehaviour, IPointerDownHandler, IPointerUpHandler
Ejemplo n.º 1
0
    private void ReadAttackInputs()
    {
        //if buttons are false
        if (Input.GetAxisRaw("HeavyAttack") == 0 && Input.GetAxisRaw("LightAttack") == 0)
        {
            m_isAxisInUse = false;
        }
        //from willy for animation combo
        if (Input.GetAxisRaw("HeavyAttack") != 0) // HeavyAttack
        {
            if (m_isAxisInUse == false)
            {
                _LastInput    = AttackButton.HeavyAttack;
                m_isAxisInUse = true;
                AkSoundEngine.PostEvent(_heavyAttackSound, gameObject);
            }
        }
        else if (Input.GetAxisRaw("LightAttack") != 0) // Light Attack
        {
            if (m_isAxisInUse == false)
            {
                _LastInput    = AttackButton.LightAttack;
                m_isAxisInUse = true;
                AkSoundEngine.PostEvent(_lightAttackSound, gameObject);
            }
        }

        if (_LastInput != AttackButton.None && _AnimationIndex == 0)
        {
            NextAnimation();
        }
    }
Ejemplo n.º 2
0
 public void Display()
 {
     attackButtons.Clear();
     for (int i = 0; i < Game.PlayerAttacks.Count; i++)
     {
         Button newButton = Instantiate(Base, Base.transform.parent);
         newButton.gameObject.SetActive(true);
         AttackButton attackButton = newButton.GetComponent <AttackButton>();
         attackButton.TheText.text = Game.PlayerAttacks[i].Name;
         attackButton.TheAttack    = Game.PlayerAttacks[i];
         RectTransform rectTransform = newButton.GetComponent <RectTransform>();
         rectTransform.anchoredPosition = rectTransform.anchoredPosition + new Vector2(0, -30 * i);
         attackButtons.Add(rectTransform);
     }
     if (attackButtons.Count <= 3)
     {
         ScrollDown.interactable = false;
         ScrollUp.interactable   = false;
     }
     else
     {
         ScrollDown.interactable = true;
         ScrollUp.interactable   = false;
     }
 }
Ejemplo n.º 3
0
    private void CreateMagicButtons()
    {
        PlayableCharacter currentChar      = HeroesToManage[0].GetComponent <CharacterStateMachine>().GetCharacter();
        List <BaseAttack> magicAttacksList = currentChar.magicAttacks;
        int CharMana = currentChar.charStats.currentMagicPoints;

        if (magicAttacksList.Count > 0)
        {
            Button magicButton = CreateButton(m_LanguageManagerInstance.GetTextValue(m_MagicTextKey));
            magicButton.onClick.AddListener(() => SwitchToMagicAttacks());
            foreach (BaseAttack magicAttack in magicAttacksList)
            {
                Button magButton = CreateButton(magicAttacksButton, m_LanguageManagerInstance.GetTextValue(magicAttack.attackName), magicSpacer, false);

                AttackButton attButton = magButton.transform.parent.GetComponent <AttackButton>();
                attButton.magicAttackToPerform = magicAttack;
                magicButtonsList.Add(magButton);

                //Controla si se puede realizar la magia
                if (magicAttack.attackCost > CharMana)
                {
                    attButton.DeactivateButton();
                }
                else if (attButton.IsDeactivated())
                {
                    attButton.ActivateButton();
                }
            }
        }
    }
Ejemplo n.º 4
0
 void Awake()
 {
     currentHexGrid   = defaultHexGrid;
     player1Camera    = defaultPlayer1Camera;
     player2Camera    = defaultPlayer2Camera;
     cardPanelPlayer1 = defaultCardPanelPlayer1;
     cardPanelPlayer2 = defaultCardPanelPlayer2;
     player2Camera.gameObject.SetActive(false);
     currentCamera              = player1Camera;
     currentPath                = new CharacterPath();
     currentAttackPath          = new CharacterPath();
     characters                 = new List <Character> ();
     attackMode                 = false;
     attackButton               = currentHexGrid.GetComponentInChildren <AttackButton> ();
     currentlySelectedCharacter = null;
     turnNumber                 = 1;
     manaText             = currentHexGrid.transform.Find("Hex Map Editor/Mana Text").GetComponent <Text>();
     maximumMana1         = 1;
     maximumMana2         = 1;
     currentMana1         = maximumMana1;
     currentMana2         = maximumMana2;
     characterObjects [0] = GameResources.wolfCharacter.GetComponent <Character>();
     characterObjects [1] = GameResources.dragonCharacter.GetComponent <Character>();
     cardDeck             = currentHexGrid.GetComponentInChildren <Deck> ();
 }
Ejemplo n.º 5
0
 void Start()
 {
     monster       = GameObject.Find("Enemy");
     monster_behav = monster.GetComponent <Monster_behavior>();
     a_button      = GameObject.Find("AttackButton");
     att           = a_button.GetComponent <AttackButton>();
 }
Ejemplo n.º 6
0
    private IEnumerator FireProjectile(AttackType _type, AttackButton _btn, float _timer)
    {
        yield return(new WaitForSeconds(_timer));

        var   projectile = Instantiate(projectilePrefab, firePoint.transform.position, firePoint.transform.rotation);
        var   rb_mult    = 0f;
        float damage     = STATS.Get_Attack_Damage(_type, _btn, Base);

        if (RelativeEnemyPosition.x > 0)
        {
            Debug.Log(RelativeEnemyPosition.x);
            rb_mult = -1f;
        }
        else
        {
            rb_mult = 1f;
        }
        if (_btn == AttackButton.Primary)
        {
            projectile.GetComponent <Projectile>()
            .ThrowProjectile(rb_mult, PNum, Base.Primary_Projectile_Sprite, Base.Primary_Projectile_Animator, _btn, damage);
        }
        else if (_btn == AttackButton.Secondary)
        {
            projectile.GetComponent <Projectile>().
            ThrowProjectile(rb_mult, PNum, Base.Secondary_Projectile_Sprite, Base.Secondary_Projectile_Animator, _btn, damage);
        }
    }
Ejemplo n.º 7
0
    //create actionbuttons
    void CreateAttackbuttons()
    {
        GameObject AttackButton     = Instantiate(actionButton) as GameObject;
        Text       AttackButtonText = AttackButton.transform.Find("Text").gameObject.GetComponent <Text>();

        AttackButtonText.text = "Attack";
        AttackButton.GetComponent <Button>().onClick.AddListener(() => Input1());
        AttackButton.transform.SetParent(actionSpacer, false);
        atkBtns.Add(AttackButton);

        GameObject MagicAttackButton     = Instantiate(actionButton) as GameObject;
        Text       MagicAttackButtonText = MagicAttackButton.transform.Find("Text").gameObject.GetComponent <Text>();

        MagicAttackButtonText.text = "Magic";
        MagicAttackButton.GetComponent <Button>().onClick.AddListener(() => Input3());
        MagicAttackButton.transform.SetParent(actionSpacer, false);
        atkBtns.Add(MagicAttackButton);
        if (HerosToManage[0].GetComponent <HeroStateMachine>().hero.MagicAttacks.Count > 0)
        {
            foreach (BaseAttack magicAttack in HerosToManage[0].GetComponent <HeroStateMachine>().hero.MagicAttacks)
            {
                GameObject MagicButton     = Instantiate(magicButton) as GameObject;
                Text       MagicButtonText = MagicButton.transform.Find("Text").gameObject.GetComponent <Text>();
                MagicButtonText.text = magicAttack.attackName;
                AttackButton ATB = MagicButton.GetComponent <AttackButton>();
                ATB.magicAttackToPerform = magicAttack;
                MagicButton.transform.SetParent(magicSpacer, false);
                atkBtns.Add(MagicButton);
            }
        }
        else
        {
            MagicAttackButton.GetComponent <Button>().interactable = false;
        }
    }
Ejemplo n.º 8
0
 void Start()
 {
     attackCollider         = transform.GetComponent <BoxCollider>();
     attackCollider.enabled = false;
     attackButton           = GameObject.Find("AttackButton").GetComponent <AttackButton>();
     cam = playerMovement.cam;
 }
Ejemplo n.º 9
0
    //creo una funzione che chiamo createAttackButtons
    void createAttackButtons()
    {
        //instazio actionButton come gameObject e lo assengo a AttackButton
        GameObject AttackButton = Instantiate(actionButton) as GameObject;
        //cerco dentro attackButton unGameObject chiamato text e cerco la componente text
        //dopo di che lo assegno ad attackButtonText
        Text attackButtonText = AttackButton.transform.Find("Text").gameObject.GetComponent <Text>();

        //cambio il text in attack
        attackButtonText.text = "Attack";
        //Utilizzo la funzione addListener per Aggiungere Input1 come funzuione ogni volta che clicco il bottone
        AttackButton.GetComponent <Button>().onClick.AddListener(() => Input1());
        //uso la funzione set parent di AttackButton e passo i parametri actionSpacer a false
        AttackButton.transform.SetParent(actionSpacer, false);
        //aggiungo l'attack button alla lista
        AtkBtns.Add(AttackButton);

        //instazio actionButton come gameObject e lo assengo a MagicAttackButton
        GameObject MagicAttackButton = Instantiate(actionButton) as GameObject;
        //cerco dentro MagicAttackButton unGameObject chiamato text e cerco la componente text
        //dopo di che lo assegno ad MagicButtonText
        Text MagicButtonText = MagicAttackButton.transform.Find("Text").gameObject.GetComponent <Text>();

        //cambio il text in Magic
        MagicButtonText.text = "Magic";
        //Utilizzo la funzione addListener per Aggiungere Input3 come funzuione ogni volta che clicco il bottone
        MagicAttackButton.GetComponent <Button>().onClick.AddListener(() => Input3());
        //uso la funzione set parent di AttackButton e passo i parametri actionSpacer a false
        MagicAttackButton.transform.SetParent(actionSpacer, false);
        //aggiungo MagicAttackButton alla lista
        AtkBtns.Add(MagicAttackButton);
        //se l'eroe non ha magie disponibili
        if (HeroToManage[0].GetComponent <HeroStateM>().hero.MagicAttack.Count > 0)
        {
            //per ogni spellAttack all interno della lista delle magie del player scelto
            foreach (BaseAttack SpellAtk in HeroToManage[0].GetComponent <HeroStateM>().hero.MagicAttack)
            {
                //instazia un magicButton
                GameObject SpellButton = Instantiate(MagicButtons);
                //assegna a SpellButtonText la componente text di MagicButton
                Text SpellButtonText = MagicButtons.transform.Find("Text").gameObject.GetComponent <Text>();
                //assegna il text di SpellButtonText al nome della spell
                SpellButtonText.text = SpellAtk.attackName;
                //assegna a ATB la componente AttackButton di MagicButton
                AttackButton ATB = MagicButtons.GetComponent <AttackButton>();
                //assegnaa ATB.magicAttackToPerform  la SpellAtk
                ATB.magicAttackToPerform = SpellAtk;
                //uso la funzione set parent di SpellButton e passo i parametri actionSpacer a false
                SpellButton.transform.SetParent(magicSpacer, false);
                //aggiungo SpellButton alla lista
                AtkBtns.Add(SpellButton);
            }
        }
        else
        {
            //imposto il componente Button di MagicAttackButton non interagibile
            MagicAttackButton.GetComponent <Button>().interactable = false;
        }
    }
Ejemplo n.º 10
0
    public static AttackButton GetARandomButton()
    {
        UnityEngine.Random.InitState((int)Time.time * (int)Time.deltaTime);
        int          rand = UnityEngine.Random.Range(0, 2);
        AttackButton _btn = (AttackButton)rand;

        return(_btn);
    }
Ejemplo n.º 11
0
 void Awake()
 {
     playerAnim      = transform.GetComponent <Animator>();
     attackTransform = transform.Find(ObjectChilds.AttackPoint).transform;
     mobs            = LayerMask.GetMask(MaskHelper.Mobs);
     playerMovement  = transform.GetComponent <PlayerMovement>();
     attackButton    = GameObject.FindGameObjectWithTag("AttackButton").GetComponent <AttackButton>();
 }
Ejemplo n.º 12
0
 /// <summary>
 /// Deselects all of the action buttons and triggers the 'AttackButtonClickedEvent'.
 /// <remarks>
 /// This function gets called by the UnityButton OnClick event
 /// </remarks>
 /// </summary>
 /// <param name="button"></param>
 public void AttackButtonClicked(AttackButton button)
 {
     if (AttackButtonClickedEvent != null && AttackButton.IsEnabled)
     {
         AttackButtonClickedEvent(GetValues());
     }
     ResetActionButtons();
     AttackButton.IsEnabled = false;
 }
Ejemplo n.º 13
0
    public AttackButton CreateAttackButton(int pos)
    {
        AttackButton tempButton = Instantiate(attackButtonPrefab, actions).GetComponent <AttackButton>();

        tempButton.unitDisplay = this;
        tempButton.position    = pos;
        attacks.Add(tempButton);
        return(tempButton);
    }
        void ReleaseDesignerOutlets()
        {
            if (AttackButton != null)
            {
                AttackButton.Dispose();
                AttackButton = null;
            }

            if (BackgroundView != null)
            {
                BackgroundView.Dispose();
                BackgroundView = null;
            }

            if (CancelButton != null)
            {
                CancelButton.Dispose();
                CancelButton = null;
            }

            if (CountButton != null)
            {
                CountButton.Dispose();
                CountButton = null;
            }

            if (DamageButton != null)
            {
                DamageButton.Dispose();
                DamageButton = null;
            }

            if (HeaderLabel != null)
            {
                HeaderLabel.Dispose();
                HeaderLabel = null;
            }

            if (HeaderView != null)
            {
                HeaderView.Dispose();
                HeaderView = null;
            }

            if (OKButton != null)
            {
                OKButton.Dispose();
                OKButton = null;
            }

            if (PlusButton != null)
            {
                PlusButton.Dispose();
                PlusButton = null;
            }
        }
Ejemplo n.º 15
0
    // Use this for initialization
    void Start()
    {
        if (spawnPoint == null)
        {
            spawnPoint = transform;
        }

        btnFire = GameObject.Find("joystick_right").GetComponent <AttackButton>();
        player  = (GameObject)GameObject.FindGameObjectWithTag("Player");
    }
Ejemplo n.º 16
0
    // Use this for initialization
    void Start()
    {
        if (instance == null)
        {
            instance = this;
        }

        Button btn = this.GetComponent <Button> ();

        btn.onClick.AddListener(OnClick);
    }
Ejemplo n.º 17
0
    // Use this for initialization
    public override void Initialize(AttackButton button)
    {
        attackButton = button;

        onAttackButtonDown = OnAttackButtonDownFunction;
        onAttackButtonUp   = OnAttackButtonUpFunction;

        TouchInputManager.instance.touchStart += OnTouchStart;
        //TouchInputManager.instance.touchMove += OnTouchMove;
        //TouchInputManager.instance.touchEnd += OnTouchEnd;
    }
Ejemplo n.º 18
0
    public void SetAttackUI(int code)
    {
        uicon.UIOnOff(code);
        switch (code)
        {
        case 0: attackButton = uicon.UI_Melee.GetComponent <AttackButton>(); ((MeleeAttackButton)attackButton).isSpear = false; break;

        case 1: attackButton = uicon.UI_Melee.GetComponent <AttackButton>(); ((MeleeAttackButton)attackButton).isSpear = true; break;

        case 2: attackButton = uicon.UI_Distance.GetComponent <AttackButton>(); break;
        }
    }
Ejemplo n.º 19
0
    public void Refresh()
    {
        BreakDown();

        switch (CurrentStep)
        {
        case PlayerControlSteps.PickBattler:

            foreach (Battler i in Battle.ActiveBattlers)
            {
                if (i.owner == Player.Player1 && i.isTargetable /*&& i.preparingAction == false*/)
                {
                    BuildAllySelectButton(i);
                }
            }

            break;

        case PlayerControlSteps.PickAttack:

            if (SelectedBattler != null)
            {
                AttackButton newButton = Instantiate(MoveSelector);
                newButton.transform.SetParent(MainCanvas.transform);
                newButton.transform.position = Camera.main.WorldToScreenPoint(SelectedBattler.transform.position);

                newButton.SourceController = this;
                newButton.PickBattler      = SelectedBattler;
            }

            break;

        case PlayerControlSteps.PickTarget:

            foreach (Battler i in ApplicableTargets(SelectedBattler.creature.Attacks[SelectedAttack].Target))
            {
                if (i.isTargetable)    // need to check applicability
                {
                    TargetSelector newButton = Instantiate(TargetSelectorPrefab);
                    newButton.transform.SetParent(MainCanvas.transform);
                    newButton.transform.position = Camera.main.WorldToScreenPoint(i.transform.position);

                    newButton.SourceController = this;
                    newButton.pick             = i;
                }
            }

            break;

        default:
            break;
        }
    }
    void Start()
    {
        M_collision_enabled         = monster_area.GetComponent <BoxCollider2D>();
        M_collision_enabled.enabled = false;

        rend            = GetComponent <Renderer>();
        rend.enabled    = true;
        monster         = GameObject.FindGameObjectWithTag("Enemy");
        next_t          = monster.GetComponent <Monster_behavior>();
        attackButton    = attack_Button.GetComponent <AttackButton>();
        m_status        = monster.GetComponent <MonsterStatus>();
        m_status.attack = false;
    }
Ejemplo n.º 21
0
 void Awake()
 {
     ButtonA         = GetComponentInChildren <AttackButton>();
     StickL          = GetComponentInChildren <LeftStick>();
     I_PlayerData    = PlayerData.Instance;
     FocusBtns       = GameObject.Find("FocusBtns");
     ScoreText       = transform.Find("ScoreTxt").GetComponent <Text>();
     MaxText         = transform.Find("MaxScoreTxt").GetComponent <Text>();
     DifficultyText  = transform.Find("DifficultyTxt").GetComponent <Text>();
     ResultPanel     = transform.Find("ResultPanel");
     DifficultyPanel = transform.Find("DifficultyPanel");
     //audioInactive = GetComponent<AudioSource>();
 }
Ejemplo n.º 22
0
 // Start is called before the first frame update
 void Start()
 {
     facingRight        = true;
     myRigidBody        = GetComponent <Rigidbody2D>();
     myAnimator         = GetComponent <Animator>();
     myBodyCollider     = GetComponent <CapsuleCollider2D>();
     myFeet             = GetComponent <CircleCollider2D>();
     myjoystick         = FindObjectOfType <Joystick>();
     myjumpbutton       = FindObjectOfType <JumpButton>();
     switchPlayerButton = FindObjectOfType <SwitchPlayerButton>();
     myattackbutton     = FindObjectOfType <AttackButton>();
     mygrabbutton       = FindObjectOfType <GrabButton>();
 }
Ejemplo n.º 23
0
    void Awake()
    {
        isAlive         = true;
        body            = GetComponent <Rigidbody2D>();
        anim            = GetComponent <Animator>();
        levelController = FindObjectOfType <LevelController>();
        health          = maxHealth;

        //Inputs Declaration
        joystick     = GameObject.Find("Canvas/Buttons/JoystickBG").GetComponent <VirtualJoystick>();
        jumpButton   = GameObject.Find("Jump").GetComponent <JumpButton>();
        attackButton = GameObject.Find("Attack").GetComponent <AttackButton>();
        throwButton  = GameObject.Find("Throw").GetComponent <ThrowButton>();
    }
Ejemplo n.º 24
0
    /// <summary>
    /// Deselects all of the action buttons and triggers the 'AttackButtonClickedEvent'.
    /// <remarks>
    /// This function gets called by the UnityButton OnClick event
    /// </remarks>
    /// </summary>
    /// <param name="button"></param>
    public void AttackButtonClicked(AttackButton button)
    {
        if (AttackButton.IsEnabled)
        {
            AttackButton.IsEnabled = false;
            ResetActionButtons();

            if (AttackButtonClickedEvent != null)
            {
                AttackButtonClickedEvent(GetValues());
            }

            buttonSequence = new ActionSequence();
        }
    }
Ejemplo n.º 25
0
    /// <summary>
    /// Deselects all of the action buttons and triggers the 'AttackButtonClickedEvent'.
    /// <remarks>
    /// This function gets called by the UnityButton OnClick event
    /// </remarks>
    /// </summary>
    /// <param name="button"></param>
    public void AttackButtonClicked(AttackButton button)
    {
        if (AttackButton.IsEnabled)
        {
            AttackButton.IsEnabled = false;
            ResetActionButtons();

            if (AttackButtonClickedEvent != null)
            {
                AttackButtonClickedEvent(GetValues());
            }

            buttonSequence = new ActionSequence();
        }
    }
Ejemplo n.º 26
0
    private IEnumerator AnimateAttack(float _cooldown, AttackButton _btn)
    {
        if (_btn == AttackButton.Primary)
        {
            playerAnim.SetTrigger("Primary_Attack");
        }
        else if (_btn == AttackButton.Secondary)
        {
            playerAnim.SetTrigger("Secondary_Attack");
        }
        playerAnim.SetBool("AttackFinished", false);
        yield return(new WaitForSeconds(_cooldown));

        isAttacking = false;
        playerAnim.SetBool("AttackFinished", true);
    }
Ejemplo n.º 27
0
    // En este bucle solamente comprobaremos si el Input nos indica "atacar" y activaremos el trigger "Attack"
    private void Update()
    {
        // Si estoy en pausa no hacer nada (no moverme ni atacar)
        if (paused)
        {
            return;
        }

        // Si detecto Input tecla/boton ataque ==> Activo disparados 'Attack'
        if (Input.GetButton("Fire") || AttackButton.IsAttack())
        {
            _animator.SetTrigger(AttackHash);
            _audioSource.clip = attackAudioClip;
            _audioSource.PlayDelayed(1.5f);
        }
    }
Ejemplo n.º 28
0
    private void SetAttackBtn(int index, string btnName)
    {
        stAttackBtn[index] = new AttackButton();

        if (objAttackBtn.transform.Find(btnName) == null)
        {
            return;
        }

        stAttackBtn[index].objRoot    = objAttackBtn.transform.Find(btnName).gameObject;
        stAttackBtn[index].objText    = stAttackBtn[index].objRoot.transform.Find("Text").gameObject;
        stAttackBtn[index].imgFront   = stAttackBtn[index].objRoot.transform.Find("Front").GetComponent <Image>();
        stAttackBtn[index].text       = stAttackBtn[index].objText.GetComponent <Text>();
        stAttackBtn[index].fMaxCount  = index * 5;
        stAttackBtn[index].fCurrCount = 0;
    }
Ejemplo n.º 29
0
 public void ThrowProjectile(float _rp, int _whoThrew, Sprite _projectileSprite, RuntimeAnimatorController _anim, AttackButton _btn, float _damage)
 {
     FromPlayer                     = _whoThrew;
     sprite_rend.sprite             = _projectileSprite;
     anim.runtimeAnimatorController = _anim;
     A_Type = _btn;
     damage = _damage;
     if (_rp == 1)
     {
         rb.velocity = transform.right * -1 * speed;
     }
     else
     {
         rb.velocity = transform.right * speed;
     }
 }
Ejemplo n.º 30
0
    private void TryAttack(AttackType _attack, AttackButton _btn)
    {
        Debug.Log(string.Format("ATTACK: {0}", _attack));
        if (_attack == AttackType.Back && Base.Back_Damage == 0f && isGrounded)
        {
            _attack = AttackType.Projectile;
        }
        if (STATS.Get_Current_Action() == Movement_Direction.Crouching)
        {
            _attack = AttackType.Crouch;
        }

        isAttacking = true;
        float   _cd     = STATS.Get_Attack_CoolDown(_attack, _btn, Base);
        float   _damage = STATS.Get_Attack_Damage(_attack, _btn, Base);
        Vector2 _range  = STATS.Get_Attack_Range(_attack, _btn, Base);

        if (_attack == AttackType.Projectile)
        {
            var CoolDownTimer = StartCoroutine(AnimateAttack(_cd, _btn));
            var co            = StartCoroutine(FireProjectile(_attack, _btn, _cd / 3));
        }
        else if (_attack == AttackType.Forward && _btn == AttackButton.Primary)
        {
            var co = StartCoroutine(FireLongAttack());
        }
        else
        {
            var          CoolDownTimer = StartCoroutine(AnimateAttack(_cd, _btn));
            Collider2D[] enemyInRange  = Physics2D.OverlapBoxAll(attackPos.position, _range, 0, MasterController.Controller.GameSettings.EnemyMask);
            for (int i = 0; i < enemyInRange.Length; ++i)
            {
                if (enemyInRange[i] != this.GetComponent <Collider2D>())
                {
                    var enemy = enemyInRange[i];
                    if (enemy.gameObject.name == "Rectangle")
                    {
                        Destroy(enemy.gameObject);
                    }
                    if (enemy != null)
                    {
                        enemy.GetComponent <Fighter>().TakeDamage(_damage, _attack, _btn);
                    }
                }
            }
        }
    }
Ejemplo n.º 31
0
 // Start is called before the first frame update
 void Start()
 {
     if (!multiplayer)
     {
         facingRight        = true;
         myRigidBody        = GetComponent <Rigidbody2D>();
         myAnimator         = GetComponent <Animator>();
         myBodyCollider     = GetComponent <CapsuleCollider2D>();
         myFeet             = GetComponent <CircleCollider2D>();
         myjoystick         = GameObject.Find("Fixed Joystick").GetComponent <Joystick>();
         myjumpbutton       = GameObject.Find("JumpButton").GetComponent <JumpButton>();
         switchPlayerButton = GameObject.Find("SwitchPlayerButton").GetComponent <SwitchPlayerButton>();
         myattackbutton     = FindObjectOfType <AttackButton>();
         //mygrabbutton = FindObjectOfType<GrabButton>();
         weaponjoystick = GameObject.Find("Fixed Joystick 2").GetComponent <FixedJoystick>();
     }
 }
Ejemplo n.º 32
0
    private void CreateAttackButtons()
    {
        if (_attackButtons.Count > 0)
        {
            _attackButtons.ForEach(Destroy);
            _attackButtons.Clear();
        }
        heroesToManage[0].GetComponent <HeroStateMachine>().hero.Attacks.ForEach(attack =>
        {
            GameObject newButton = Instantiate(attackButtonPrefab, _attackSpacer, false);
            newButton.transform.Find("Text").GetComponent <Text>().text = attack.attackName;

            AttackButton atkBtn = newButton.GetComponent <AttackButton>();
            atkBtn.Attack       = attack;

            _attackButtons.Add(newButton);
        });
    }
Ejemplo n.º 33
0
 void Awake()
 {
     _instance = this;
 }
Ejemplo n.º 34
0
 /// <summary>
 /// Searches for the Action and Attack Button(s) within the game object's children and saves them for ongoing reference.
 /// </summary>
 void SetButtons()
 {
     ActionButtons = gameObject.GetComponentsInChildren<ActionButton>();
     AttackButton = gameObject.GetComponentInChildren<AttackButton>();
 }