Esempio n. 1
0
        private void Update()
        {
            if (!isLocalPlayer)
            {
                return;
            }


            if (!m_Jump)
            {
                // Read the jump input in Update so button presses aren't missed.
                m_Jump = CrossPlatformInputManager.GetButtonDown("Jump");
            }


            bool useItem = CrossPlatformInputManager.GetButton("Item");

            //bool useItem = Input.GetKey(KeyCode.Alpha5);


            if (useItem && !item.Equals(""))
            {
                if (item.Equals("Item1"))
                {
                    //CmdBulletFire();
                    CmdBlackHoleFire();
                }

                if (item.Equals("Item2"))
                {
                    CmdBombFire();
                }

                if (item.Equals("Item3"))
                {
                    CmdSyringeFire();
                }
                if (item.Equals("Item4"))
                {
                    CmdRocketsFire();
                }
                item    = "";
                itemNum = 0;
            }


            //Player has item
            if (!item.Equals(""))
            {
                if (item.Equals("Item2"))
                {
                    itemNum = 2;
                }
                if (item.Equals("Item3"))
                {
                    itemNum = 3;
                }
            }

            m_Anim.SetInteger("Item", itemNum);

            syringeCdTimer -= Time.deltaTime;

            if (isStunned)
            {
                stunDuration -= Time.deltaTime;
                if (stunDuration <= 0)
                {
                    isStunned = false; print("no more stun");
                    statusNum = 0;
                    CmdsendStatus(0);
                    m_status.Status(0);
                }
            }
            if (slowMultiplier != 1)
            {
                slowDuration -= Time.deltaTime;
                if (slowDuration <= 0)
                {
                    slowMultiplier = 1; print("no more slow");
                    CmdsendStatus(0);
                    m_status.Status(0);
                }
            }

            if (inStasis)
            {
                stasisDuration -= Time.deltaTime;
                if (stasisDuration <= 0)
                {
                    GetComponent <Rigidbody2D>().constraints = RigidbodyConstraints2D.FreezeRotation;
                    inStasis = false;
                    CmdsendStatus(0);
                    m_status.Status(0);
                }
            }
            else
            {
                GetComponent <Rigidbody2D>().constraints = RigidbodyConstraints2D.FreezeRotation;
            }
        }
Esempio n. 2
0
        private void Update()
        {
            // set controlling the player only to local player
            if (!isLocalPlayer)
            {
                return;
            }


            // Set jump only if jump is not true has not been pressed, this prevents double jumping
            if (!m_Jump)
            {
                // Read the jump input in Update so button presses aren't missed.
                m_Jump = CrossPlatformInputManager.GetButtonDown("Jump");
            }


            //When item button is pressed, player will use the item they have in hand
            bool useItem = CrossPlatformInputManager.GetButton("Item");

            //If button is pressed and item is available, check which item the player has and use it
            if (useItem && !item.Equals(""))
            {
                //Sends spawn information to the server
                if (item.Equals("Item1"))
                {
                    CmdBlackHoleFire();
                }

                else if (item.Equals("Item2"))
                {
                    CmdBombFire();
                }

                else if (item.Equals("Item3"))
                {
                    CmdSyringeFire();
                }
                else if (item.Equals("Item4"))
                {
                    CmdRocketsFire();
                }
                // Resets item information, the player will have used the item at thsi point
                item    = "";
                itemNum = 0;
            }


            //Player has item
            //sprite animator reads itemNum to determine what item the player is holding
            if (!item.Equals(""))
            {
                if (item.Equals("Item2"))
                {
                    itemNum = 2;
                }
                if (item.Equals("Item3"))
                {
                    itemNum = 3;
                }
            }
            //Sets animator to correspong to the correct item number
            m_Anim.SetInteger("Item", itemNum);


            //status effect timers update here
            if (isStunned)
            {
                stunDuration -= Time.deltaTime;
                if (stunDuration <= 0)
                {
                    isStunned = false; print("no more stun");
                    // reset status to normal locally and on server.
                    statusNum = 0;
                    CmdsendStatus(0);
                    m_status.Status(0);
                }
            }
            if (slowMultiplier != 1)
            {
                slowDuration -= Time.deltaTime;
                if (slowDuration <= 0)
                {
                    slowMultiplier = 1; print("no more slow");
                    // reset status to normal locally and on server.
                    CmdsendStatus(0);
                    m_status.Status(0);
                }
            }

            if (inStasis)
            {
                stasisDuration -= Time.deltaTime;
                if (stasisDuration <= 0)
                {
                    // reset status to normal locally and on server.
                    GetComponent <Rigidbody2D>().constraints = RigidbodyConstraints2D.FreezeRotation;
                    inStasis = false;
                    CmdsendStatus(0);
                    m_status.Status(0);
                }
            }
            //if status is normal release all constraints
            else
            {
                GetComponent <Rigidbody2D>().constraints = RigidbodyConstraints2D.FreezeRotation;
            }
        }