Пример #1
0
    private IEnumerator LookForPlayer()
    {
        if ((playerController = FindObjectOfType <PlayerController>()) == null)
        {
            yield return(new WaitForSeconds(0.5f));

            StartCoroutine(LookForPlayer());
        }
        else
        {
            if (itemPickup != null)
            {
                itemPickup.Interact();
            }
            else if (hpAmount != 0)
            {
                FindObjectOfType <LaunchRewards>().LanuchHPRewardbox(hpAmount);
            }
            else if (gaiaAmount != 0)
            {
                FindObjectOfType <LaunchRewards>().LanuchGaiaRewardbox(gaiaAmount);
            }
            else if (goldenAcornAmount != 0)
            {
                FindObjectOfType <LaunchRewards>().LanuchGARewardbox(goldenAcornAmount);
            }

            Destroy(gameObject);
        }
    }
Пример #2
0
    void Update()
    {
        if (Input.GetMouseButtonDown(1))
        {
            Ray        ray = cam.ViewportPointToRay(new Vector3(0.5f, 0.5f, 0));
            RaycastHit hit;

            if (Physics.Raycast(ray, out hit, interactionMask))
            {
                ItemPickup osuma = hit.collider.GetComponent <ItemPickup>();
                if (osuma != null)
                {
                    osuma.Interact();
                }
            }
        }
    }
Пример #3
0
 private void GiveSeed()
 {
     itemPickup.Interact();
     FindObjectOfType <PlayerController>().onFinishedInteractingCallback -= GiveSeed;
 }
Пример #4
0
    private void Update()
    {
        if (EventSystem.current.IsPointerOverGameObject())
        {
            return;
        }

        if (!GameManager.instance.playersTurn || GameManager.instance.gameOver)
        {
            return;
        }

        Vector2 move = new Vector2(0, 0);

        if (Input.GetKey(KeyCode.A)) // -x
        {
            move = Vector2.left;
        }
        else if (Input.GetKey(KeyCode.D)) // +x
        {
            move = Vector2.right;
        }
        else if (Input.GetKey(KeyCode.W)) // +z
        {
            move = Vector2.up;
        }
        else if (Input.GetKey(KeyCode.S)) // -z
        {
            move = Vector2.down;
        }
        else if (Input.GetKey(KeyCode.E)) // item pickup key
        {
            foreach (Transform item in GameManager.instance.items)
            {
                ItemPickup currItem = item.GetComponent <ItemPickup>();
                if (currItem.CanPickup(transform.position))
                {
                    currItem.Interact(); // interact with first item in list
                    GameManager.instance.playersTurn = false;

                    if (GameManager.instance.isTutorial)
                    {
                        TutorialManager.instance.ChallengeTrigger(TutorialState.PICKUP);
                    }

                    return;
                }
            }
        }

        // god mode commands
        if (PlayerController.instance.isGodMode)
        {
            if (Input.GetKeyDown(KeyCode.L))
            { // next level
                GameManager.instance.LevelComplete();
                GameManager.instance.playersTurn = false;
            }
            else if (Input.GetKeyDown(KeyCode.K)) // kill all in radius
            {
                foreach (EnemyController enemy in GameManager.instance.enemies.ToArray())
                {
                    if ((enemy.transform.position - PlayerController.instance.transform.position).sqrMagnitude < 9)
                    {
                        enemy.GetComponent <EnemyStats>().Die();
                    }
                }
                GameManager.instance.playersTurn = false;
            }
        }

        // Check for legal move, give relevant actions
        if (move != new Vector2(0, 0))
        {
            if (GameManager.instance.isTutorial)
            {
                TutorialManager.instance.ChallengeTrigger(TutorialState.MOVEMENT);
            }

            Vector3    dest = transform.position + new Vector3(move.x, 0, move.y);
            RaycastHit hit;
            if (!Physics.Linecast(transform.position, dest, out hit))
            {
                movement.AttemptMove(move);
            }
            else if (hit.transform.tag == "Enemy")
            {
                movement.RotateToDir(move);

                hit.transform.GetComponent <EnemyController>().Interact();
            }
            else if (hit.transform.name.Contains("fbBrickWall"))
            {
                MessageUI.instance.Log("There's a wall in the way!", Color.white);
            }
            else if (hit.transform.name.Contains("fbBrickVase"))
            {
                MessageUI.instance.Log("There's a vase in the way!", Color.white);
            }

            // Regen health randomly
            if (!isGodMode && Random.Range(0f, 1f) <= healthRegenChance)
            {
                stats.RegenHealth(healthRegenRange.Random);
            }

            GameManager.instance.playersTurn = false;
        }
    }