Exemple #1
0
    private void Update()
    {
        if(m_Controller == null)
        {
            m_Hero.ChangeHeroController();
            m_Controller = m_Hero.m_Controller;
            m_AnimationController.ChangeAnimator();
        }
        else if(m_Controller != m_Hero.m_Controller)
        {
            m_Controller = m_Hero.m_Controller;
            m_AnimationController.ChangeAnimator();
        }
        else if(m_Hero.m_iHeroHealth > 0)
        {
            if (!m_bJump)
            {
                // Read the jump input in Update so button presses aren't missed.
                m_bJump = Input.GetButtonDown(InputBank.JUMP+m_Hero.m_iHeroId);
                m_bDash = Input.GetButtonDown(InputBank.DASH+m_Hero.m_iHeroId);
                m_bAttack = Input.GetButtonDown(InputBank.ATTACK+m_Hero.m_iHeroId);
                m_bCharge = Input.GetButton(InputBank.ATTACK+m_Hero.m_iHeroId);
            }

            m_bJumpHold = Input.GetButton(InputBank.JUMP+m_Hero.m_iHeroId);

            if(Input.GetButtonDown(InputBank.SWORD+m_Hero.m_iHeroId))
            {
                if(!m_Controller.m_isSpinning && !m_Controller.m_isAttacking)
                {
                    m_Hero.DropSword();
                    m_Hero.ChangeHeroController();
                }
            }

            float fVertical = Input.GetAxis(InputBank.VERTICAL+m_Hero.m_iHeroId);
            float fHorizontal = Input.GetAxis(InputBank.HORIZONTAL+m_Hero.m_iHeroId);

            fVertical = fVertical * 0.8f;

            m_Controller.Move(fHorizontal, fVertical, m_bJump, m_bDash, m_bJumpHold);
            m_Controller.Attack(fHorizontal, m_bAttack, m_bCharge);

            m_bJump = false;
            m_bDash = false;
            m_bAttack = false;
            m_bCharge = false;
        }
    }
Exemple #2
0
 internal void ChangeHeroController()
 {
     if(m_bHasSword)
         m_Controller = GetComponent<HeroControllerSword>();
     else
         m_Controller = GetComponent<HeroControllerNoSword>();
 }
Exemple #3
0
    void Start()
    {
        if(Game.Instance.IsLocalGame)
            return;

            networkClient = GameObject.Find("NetworkManager").GetComponent<NetworkManager>().client;
            latencyText = GameObject.Find("LatencyText").GetComponent<Text>();
            lerpRate = normalLerpRate;
            heroController = GetComponent<HeroBaseController>();

            if(!isLocalPlayer)
            {
                GetComponent<UserControls>().enabled = false;
                // This will prevent it from calculating physics. If it wont ever be needed we should just remove it
                GetComponent<Rigidbody2D>().isKinematic = true;
            }
            else if(isLocalPlayer)
            {
                FindObjectOfType<CameraController>().Init(this.transform);
            }

            if(isServer)
                GameObject.Find("ServerOrClient").GetComponent<Text>().text = "Server";
    }