예제 #1
0
 void RestartGame()
 {
     Debug.Log("reload");
     MessagingManager.Broadcast(Messages.RESTART, this.gameObject);
     isRound             = false;
     victory1Image.color = Color.clear;
     victory2Image.color = Color.clear;
     useTimer            = false;
     //Application.LoadLevel(Application.loadedLevel);
 }
예제 #2
0
    public void OnDeath()
    {
        if (!_isDead)
        {
            Debug.Log("This");
            Transform parent = transform.parent;

            //foreach (DetonatePlayer d in GetComponentInChildren<DetonatePlayer>())
            //{
            //    d.OnDeath();
            //}

            //foreach (Collider c in parent.GetComponentsInChildren<Collider>())
            //{
            //c.enabled = true;
            //if (c.GetComponent<DealDamageOnCollision>()) c.GetComponent<DealDamageOnCollision>().enabled = false;
            //}

            foreach (RotateAroundAxis r in GetComponentsInChildren <RotateAroundAxis>())
            {
                r.enabled = false;
            }

            if (weaponBase != null)
            {
                weaponBase.transform.parent = this.transform.parent;
            }
            else
            {
                Debug.LogError("Need to set weapon base for process");
            }

            foreach (DealDamageOnCollision d in GetComponentsInChildren <DealDamageOnCollision>())
            {
                d.enabled = false;
            }

            GetComponent <Rigidbody>().useGravity  = true;
            GetComponent <Rigidbody>().constraints = RigidbodyConstraints.None;
            GetComponentInParent <PlayerAnimationHandler>().enabled = false;
            GetComponentInParent <Animator>().enabled         = false;
            GetComponent <RigidBodyTopDownMovement>().enabled = false;
            //transform.FindChild("BodyP/HeadP").parent = transform.parent;

            foreach (Transform t in GetComponentInChildren <Transform>())
            {
                t.parent = transform.parent;
            }

            MessagingManager.Broadcast(Messages.DEATH, this.transform.parent.gameObject);
            _isDead = true;
        }
    }
예제 #3
0
    // Update is called once per frame
    void Update()
    {
        if (Time.timeScale == 0)
        {
            if ((LeftRight <= -0.7) || (LeftRightAlt <= -0.7) || (Input.GetKeyDown(KeyCode.LeftArrow)))
            {
                if (!hasExecuted)
                {
                    isResume = !isResume;
                    resume.SetHighlight(isResume);
                    back.SetHighlight(!isResume);
                    hasExecuted = true;
                }
            }
            else if ((LeftRight >= 0.7) || (LeftRightAlt >= 0.7) || (Input.GetKeyDown(KeyCode.RightArrow)))
            {
                if (!hasExecuted)
                {
                    isResume = !isResume;
                    resume.SetHighlight(isResume);
                    back.SetHighlight(!isResume);
                    hasExecuted = true;
                }
            }
            else
            {
                hasExecuted = false;
            }

            if (Input.GetKeyDown(KeyCode.Return) ||
                Input.GetKeyDown("joystick 1 button 9") ||
                Input.GetKeyDown("joystick 2 button 9") ||
                Input.GetKeyDown("joystick 3 button 9") ||
                Input.GetKeyDown("joystick 1 button 7") ||
                Input.GetKeyDown("joystick 2 button 7") ||
                Input.GetKeyDown("joystick 3 button 7"))
            {
                if (isResume)
                {
                    MessagingManager.Broadcast(Messages.RESUME, this.gameObject);
                }
                else
                {
                    Resume();
                    Application.LoadLevel("MainMenuTest");
                }
            }
        }

        else if (Input.GetKeyDown(KeyCode.P) ||
                 Input.GetKeyDown("joystick 1 button 9") ||
                 Input.GetKeyDown("joystick 2 button 9") ||
                 Input.GetKeyDown("joystick 3 button 9") ||
                 Input.GetKeyDown("joystick 1 button 7") ||
                 Input.GetKeyDown("joystick 2 button 7") ||
                 Input.GetKeyDown("joystick 3 button 7"))
        {
            MessagingManager.Broadcast(Messages.PAUSE, this.gameObject);
            isResume = true;
            back.SetHighlight(!isResume);
            resume.SetHighlight(isResume);
        }

        if ((useTimer) && (Time.time > targetTime))
        {
            if (player1Victory || player2Victory)
            {
                Application.LoadLevel("MainMenuTest");
            }
            RestartGame();
        }
    }