Esempio n. 1
0
 // Update is called once per frame
 void Update()
 {
     if (Input.GetKey(KeyCode.UpArrow))
     {
         rigidbody.AddForce(new Vector3(0f, 0f, this.force));
     }
     else if (Input.GetKey(KeyCode.DownArrow))
     {
         rigidbody.AddForce(new Vector3(0f, 0f, -this.force));
     }
     else if (Input.GetKey(KeyCode.LeftArrow))
     {
         rigidbody.AddForce(new Vector3(-this.force, 0f, 0f));
     }
     else if (Input.GetKey(KeyCode.RightArrow))
     {
         rigidbody.AddForce(new Vector3(this.force, 0f, 0f));
     }
     else if (Input.GetKey(KeyCode.Space))
     {
         GameState.GetInstance().MainState = MainState.GAME;
         if (GameState.GetInstance().GameSubState == GameSubState.LOST)
         {
             GameState.GetInstance().GameSubState = GameSubState.RUNNING;
             SignalSystem.SignalTriggered(new ResetSignal());
         }
         Time.timeScale = 1;
     }
 }
Esempio n. 2
0
    private void ShowMainMenu()
    {
        float buttonWidth   = 200;
        float buttonHeight  = 40;
        float buttonOffeset = 20;

        float shiftY = buttonHeight + buttonOffeset;

        float posX = (Screen.width - buttonWidth) / 2f;
        float posY = Screen.height / 4f;

        if (GUI.Button(new Rect(posX, posY, buttonWidth, buttonHeight), "Play"))
        {
            GameState.GetInstance().MainState = MainState.GAME;
            if (GameState.GetInstance().GameSubState == GameSubState.LOST)
            {
                GameState.GetInstance().GameSubState = GameSubState.RUNNING;
                SignalSystem.SignalTriggered(new ResetSignal());
            }
            Time.timeScale = 1;
        }

        posY += shiftY;
        if (GUI.Button(new Rect(posX, posY, buttonWidth, buttonHeight), "Exit"))
        {
            Application.Quit();
        }
        posY += shiftY;
    }
Esempio n. 3
0
 void OnCollisionEnter(Collision collision)
 {
     SignalSystem.SignalTriggered(new PointSignal(Points));
     if (isSwitch)
     {
         SignalSystem.SignalTriggered(new OpenForceFieldSignal());
     }
 }
Esempio n. 4
0
 public void HitSwitch()
 {
     --this.switchCount;
     if (this.switchCount <= 0)
     {
         if (this.forceField != null)
         {
             SignalSystem.SignalTriggered(new PlaySound(3));
             Destroy(this.forceField);
             this.forceField  = null;
             this.deleteTiles = true;
             this.life        = Mathf.Min(this.life + 5, 17);
             this.hard       -= 0.1f;
         }
     }
 }
Esempio n. 5
0
 void OnCollisionEnter(Collision collision)
 {
     SignalSystem.SignalTriggered(new DamageSignal(-1));
 }
Esempio n. 6
0
 void OnTriggerEnter(Collider col)
 {
     Destroy(col.gameObject);
     SignalSystem.SignalTriggered(new PointSignal(10));
     SignalSystem.SignalTriggered(new PlaySound(0));
 }
Esempio n. 7
0
 public void SignalTrigered(DamageSignal damage)
 {
     ChangeLife(damage.Damage);
     SignalSystem.SignalTriggered(new PlaySound(4));
 }