コード例 #1
0
 private void Start()
 {
     RightKey.DeActivateKey();
     UpKey.DeActivateKey();
     DownKey.DeActivateKey();
     LeftKey.DeActivateKey();
     RKey.DeActivateKey();
     GameManager.AddInfection(this);
 }
コード例 #2
0
 private void EndGame()
 {
     gameCodes.Clear();
     gameStarted = false;
     RightKey.DeActivateKey();
     UpKey.DeActivateKey();
     DownKey.DeActivateKey();
     LeftKey.DeActivateKey();
     RKey.DeActivateKey();
 }
コード例 #3
0
ファイル: Condition.cs プロジェクト: cdhanna/WordDialogHelper
 public bool Equals(Condition other)
 {
     if (other == null)
     {
         return(false);
     }
     return(LeftKey.Equals(other.LeftKey) &&
            RightKey.Equals(other.RightKey) &&
            Operator.Equals(other.Operator) &&
            Negated.Equals(other.Negated));
 }
コード例 #4
0
    public void OnTriggerExit2D(Collider2D collision)
    {
        Player p = collision.gameObject.GetComponent <Player>();

        if (p == null)
        {
            return;
        }
        entered = false;
        Debug.Log("Exited range of infection :(");
        Player.EnableCure(false);
        Player.UnSubscribePlayerKeyPressEvent(OnPlayerKeyPress);
        RightKey.DeActivateKey();
        UpKey.DeActivateKey();
        DownKey.DeActivateKey();
        LeftKey.DeActivateKey();
        RKey.DeActivateKey();
        if (gameStarted)
        {
            gameStarted = false;
        }
    }
コード例 #5
0
    private IEnumerator MiniGameEnumeration()
    {
        currentCheck = KeyCode.None;
        float currentCooldown = GameProperties.GetCheckTime();

        while (gameStarted)
        {
            //get new check
            if (currentCheck == KeyCode.None)
            {
                currentCheck = gameCodes.Dequeue();
            }

            switch (currentCheck)
            {
            case KeyCode.UpArrow:
                RightKey.DeActivateKey();
                UpKey.ActivateKey();
                DownKey.DeActivateKey();
                LeftKey.DeActivateKey();
                RKey.DeActivateKey();
                break;

            case KeyCode.RightArrow:
                RightKey.ActivateKey();
                UpKey.DeActivateKey();
                DownKey.DeActivateKey();
                LeftKey.DeActivateKey();
                RKey.DeActivateKey();
                break;

            case KeyCode.DownArrow:
                RightKey.DeActivateKey();
                UpKey.DeActivateKey();
                DownKey.ActivateKey();
                LeftKey.DeActivateKey();
                RKey.DeActivateKey();
                break;

            case KeyCode.LeftArrow:
                RightKey.DeActivateKey();
                UpKey.DeActivateKey();
                DownKey.DeActivateKey();
                LeftKey.ActivateKey();
                RKey.DeActivateKey();
                break;
            }

            //start timer
            currentCooldown = GameProperties.GetCheckTime();

            while (currentFramePressed != currentCheck)
            {
                yield return(new WaitForEndOfFrame());

                currentCooldown -= Time.fixedDeltaTime;
                if (currentCooldown < 0)
                {
                    Debug.Log("FAIL");
                    EndGame();
                    yield break;
                }
            }

            currentCheck = KeyCode.None;
            //check if any left
            if (gameCodes.Count == 0)
            {
                Debug.Log("WIN");
                GameManager.RemoveInfection(this);
                transform.parent.GetComponent <SpriteRenderer>().enabled = false;
                Destroy(gameObject);
                yield break;
            }
        }
    }
コード例 #6
0
ファイル: Cursor.cs プロジェクト: sol-vin/EntityEngineV4
 public bool ButtonPressed()
 {
     return(UpKey.Down() || DownKey.Down() || LeftKey.Down() || RightKey.Down());
 }
コード例 #7
0
ファイル: Cursor.cs プロジェクト: sol-vin/EntityEngineV4
        public override void Update(GameTime gt)
        {
            if (AutoSwitchInputs) //Switch the inputs
            {
                if (Input != MovementInput.Analog && AnalogStickMoved())
                {
                    Input = MovementInput.Analog;
                    EntityGame.Log.Write("Input switched to Analog", this, Alert.Info);
                }
                else if (Input != MovementInput.Buttons && ButtonPressed())
                {
                    Input = MovementInput.Buttons;
                    EntityGame.Log.Write("Input switched to Buttons", this, Alert.Info);
                }
            }



            switch (Input)
            {
            case MovementInput.Analog:
                if (!HasFocus && (AnalogStickMoved() || SelectKey.Down()))
                {
                    GetFocus(this);
                }
                if (HasFocus)
                {
                    //TODO: Use normalized positition for this.
                    Position = new Vector2(Position.X + AnalogStick.Position.X * MovementSpeed.X,
                                           Position.Y - AnalogStick.Position.Y * MovementSpeed.Y);

                    //Move it with the camera.
                    //Position += EntityGame.Camera.Delta;

                    //Keep it from leaving the bounds of the window.
                    if (Body.Position.X < EntityGame.ActiveCamera.ScreenSpace.Left)
                    {
                        Body.Position.X = EntityGame.ActiveCamera.ScreenSpace.Left;
                    }
                    else if (Body.BoundingRect.Right > EntityGame.ActiveCamera.ScreenSpace.Right)
                    {
                        Body.Position.X = EntityGame.ActiveCamera.ScreenSpace.Right - Body.Bounds.X;
                    }

                    if (Body.Position.Y < EntityGame.ActiveCamera.ScreenSpace.Top)
                    {
                        Body.Position.Y = EntityGame.ActiveCamera.ScreenSpace.Top;
                    }
                    else if (Body.BoundingRect.Bottom > EntityGame.ActiveCamera.ScreenSpace.Bottom)
                    {
                        Body.Position.Y = EntityGame.ActiveCamera.ScreenSpace.Bottom - Body.Bounds.Y;
                    }
                }
                break;

            case MovementInput.Buttons:
                if (!HasFocus && ButtonPressed() || SelectKey.Down())
                {
                    GetFocus(this);
                }
                if (HasFocus)
                {
                    Position = new Vector2(
                        Position.X + ((LeftKey.Down()) ? -MovementSpeed.X : 0) + ((RightKey.Down()) ? MovementSpeed.X : 0),
                        Position.Y + ((UpKey.Down()) ? -MovementSpeed.Y : 0) + ((DownKey.Down()) ? MovementSpeed.Y : 0)
                        );

                    //Move it with the camera.
                    Position += EntityGame.ActiveCamera.Delta;

                    //Keep it from leaving the bounds of the window.
                    if (Body.Position.X < EntityGame.ActiveCamera.ScreenSpace.Left)
                    {
                        Body.Position.X = EntityGame.ActiveCamera.ScreenSpace.Left;
                    }
                    else if (Body.BoundingRect.Right > EntityGame.ActiveCamera.ScreenSpace.Right)
                    {
                        Body.Position.X = EntityGame.ActiveCamera.ScreenSpace.Right - Body.Bounds.X;
                    }

                    if (Body.Position.Y < EntityGame.ActiveCamera.ScreenSpace.Top)
                    {
                        Body.Position.Y = EntityGame.ActiveCamera.ScreenSpace.Top;
                    }
                    else if (Body.BoundingRect.Bottom > EntityGame.ActiveCamera.ScreenSpace.Bottom)
                    {
                        Body.Position.Y = EntityGame.ActiveCamera.ScreenSpace.Bottom - Body.Bounds.Y;
                    }
                }
                break;
            }
            base.Update(gt);
        }