Пример #1
0
    // when something collides with the button
    private void OnTriggerEnter(Collider other)
    {
        // if it is the player that owns the button
        if (other.gameObject == Player)

        {
            // array of all things colliding with the base
            Collider[] hitColliders = Physics.OverlapSphere(PlayerBase.transform.position, distroyRadius);

            //for each thing that is colliding with the base itterate
            foreach (Collider current in hitColliders)
            {
                //if one of the things is a player then respawn them
                if (current.gameObject.tag == "Player")
                {
                    PlayerControllerXbox playerChomped = current.gameObject.GetComponent <PlayerControllerXbox>();
                    playerChomped.DropCollectables();
                    playerChomped.ResetToSpawn();
                }
            }
            //venusAnim.SetBool("venusBite", true);
            venusAnim.SetTrigger("venusBite");
            StartCoroutine(playercontrol.VenusChomp());
            playercontrol.PlayBellSound();
        }
    }//on exit reset venus bite bool to false to go back to idle (have to do this so that the animation can finish)
Пример #2
0
    // Update is called once per frame
    void Update()
    {
        PlayerControllerXbox playerscripter = player.GetComponent <PlayerControllerXbox>();
        int maxPancake       = playerscripter.maxHeldCollectables;
        int heldPancakeCount = playerscripter.heldCollectables;

        pancakeCount.fillAmount = heldPancakeCount / (float)maxPancake;
    }
Пример #3
0
    // Update is called once per frame
    void Update()
    {
        PlayerControllerXbox playerscript = player.GetComponent <PlayerControllerXbox>();//max
        float maxCoolDownTime             = playerscript.tongueCooldown;
        float currentCoolDownTime         = playerscript.currentCooldown;

        if (currentCoolDownTime > 0f)
        {
            coolDownImage.fillAmount = 1 - (currentCoolDownTime / maxCoolDownTime);
        }
        else
        {
            coolDownImage.fillAmount = 1;
        }
    }
Пример #4
0
    /// <summary>
    /// Deals with interaction between player and base
    /// </summary>
    /// <param name="other">The collider that is colliding with the gameObject</param>
    /// <returns>Used for the WaitForSeconds function</returns>
    private IEnumerator OnTriggerEnter(Collider other)
    {
        //if it is the players base do code, if not nothing happens
        if (other.gameObject.transform == player)
        {
            //getting script from PlayerControllerXbox
            PlayerControllerXbox playercontrol = other.gameObject.GetComponent <PlayerControllerXbox>();
            int collectablesHeld = playercontrol.heldCollectables;
            playercontrol.heldCollectables = 0;

            //if no script found load error
            if (playercontrol == null)
            {
                Debug.Log("No script");
            }
            // otherwise
            else
            {
                // the max allowed to spawn in this instance is equal to how many pancakes the player is holding
                spawner.maxSpawn += collectablesHeld;

                //spawn the amount the player is holding with frozen transforms and a delay between spawns
                for (int i = 0; i < collectablesHeld; i++)
                {
                    SpawnObject().GetComponent <Rigidbody>().constraints =
                        RigidbodyConstraints.FreezePositionX |
                        RigidbodyConstraints.FreezePositionZ |
                        RigidbodyConstraints.FreezeRotation;

                    yield return(new WaitForSeconds(delay));
                }
                // the max spawn is returned to 0.
                spawner.maxSpawn = 0;
            }
        }
    }
    /// <summary>
    /// Deals with interaction with players
    /// </summary>
    /// <param name="other">The GameObject that is colliding with the collectable</param>
    private void OnTriggerEnter(Collider other)
    {
        // If not a player then ignore interaction
        if (other.gameObject.tag != "Player")
        {
            return;
        }

        // Reference to the player script
        PlayerControllerXbox player = other.gameObject.GetComponent <PlayerControllerXbox>();

        if (player == null)
        {
            Debug.LogError("No script on player");
        }

        // If the players tongue is not attached
        if (player.objectHit != this.gameObject || player.tongueHit != HitType.COLLECTABLE)
        {
            // Ignore interaction
            return;
        }

        // Add to the amount that the player is holding
        player.heldCollectables += stackSize;
        // Unset from what the tongue is attached to
        player.objectHit = null;
        // Set the tongue interaction to none
        player.tongueHit = HitType.NONE;
        // Set cool-down to start
        player.currentCooldown = player.tongueCooldown;
        // Destroy collectable
        Destroy(this.gameObject);
        // Play sound to indicate that the player has picked up a collectable.
        player.PlayPickUpSound();
    }
Пример #6
0
    // Update is called once per frame
    void Update()
    {
        // Countdown timer
        currentCooldown -= Time.deltaTime;

        if (currentCooldown - animationDelay < 0 /* && !animationPlayed*/)
        {
            // Play animation
            StartCoroutine(PlayVenusAnimation());
            animationPlayed = true;
        }
        // If countdown is completed
        if (currentCooldown < 0)
        {
            animationPlayed = false;
            // Calculate position that attack is taking place
            Vector3 attackPoint = transform.TransformPoint(attackOffset);
            // Get everything in that area
            Collider[] inAttackRange = Physics.OverlapSphere(attackPoint, attackRadius);
            foreach (Collider current in inAttackRange)
            {
                // If the thing is a player
                if (current.tag == "Player")
                {
                    // Get the player script
                    PlayerControllerXbox player = current.GetComponent <PlayerControllerXbox>();
                    // Trip the player
                    player.TripPlayer();
                }
            }
            currentCooldown = attackCooldown;
            //anim.SetBool("venusBite", false);
        }

        //anim.ResetTrigger("venusBite");
    }
Пример #7
0
 /// <summary>
 /// Cache the things that are expensive to call
 /// </summary>
 void Start()
 {
     playerController = player.GetComponent <PlayerControllerXbox>();
     baseStashAmount  = Base.GetComponent <BaseStash>();
     flickeringLight  = GetComponent <Light>();
 }
Пример #8
0
 private void Start()
 {
     playercontrol = Player.GetComponent <PlayerControllerXbox>();
 }
Пример #9
0
    /// <summary>
    /// Used to calculate what the tongue should be interacting with
    /// </summary>
    private void TongueLash()
    {
        // Used to calculate the Capsule for the CapsuleCast
        Vector3 pointModifier = new Vector3(0, (playerHeight / 2) + tongueFireRadius, 0);

        // Casts sphereCast. hit = The object that the circleCast hits if it hits something
        if (Physics.CapsuleCast(transform.position + pointModifier, // First point in capsule
                                transform.position - pointModifier, // Second point in capsule
                                tongueFireRadius,                   // Radius of Capsule
                                transform.forward,                  // Direction
                                out RaycastHit hit,                 // Output
                                300f))                              // Distance (If map gets really big then this number might need to be increased)
        {
            // Set defaults
            currentGrappleTime = 0f;
            // Reset player state and tongue hit
            DisconnectTongue();
            // Remove any existing points in tongue
            tongueHitPoints.Clear();
            // Set the first position to zero because it's calculated in update
            tongueHitPoints.Add(Vector3.zero);
            // Set where the tongue has hit
            tongueHitPoints.Add(StandardisePosition(hit.point));
            // Set what it hit.
            objectHit = hit.collider.gameObject;

            // If the tongue has hit a wall or other environment
            if ((environmentLayer.value & (1 << objectHit.layer)) != 0)
            {
                tongueHit = HitType.ENVIRONMENT;
                // Set cooldown
                currentCooldown = tongueCooldown;
            }
            // If the tongue has hit a collectable
            else if ((collectableLayer.value & (1 << objectHit.layer)) != 0)
            {
                // Get the script from the collectable
                CollectableController collectable = objectHit.GetComponent <CollectableController>();
                // If the collectable is a stack then grab only one
                if (collectable.stackSize > 1)
                {
                    collectable.stackSize--;
                    objectHit = Instantiate(collectablePrefab,
                                            objectHit.transform.position,
                                            objectHit.transform.rotation);
                }
                tongueHit = HitType.COLLECTABLE;
                // Freeze the rotation of the collectable to make pulling more smooth
                objectHit.GetComponent <Rigidbody>().constraints = RigidbodyConstraints.FreezeRotation;
            }
            // If you hit another player
            else if (objectHit.tag == "Player")
            {
                PlayerControllerXbox player = objectHit.GetComponent <PlayerControllerXbox>();
                // If the player has something to steal
                if (player.heldCollectables > 0)
                {
                    // Remove one from how many they are holding
                    player.heldCollectables--;
                    // Create new collectable at position of player
                    objectHit = Instantiate(collectablePrefab,
                                            objectHit.transform.position,
                                            objectHit.transform.rotation);

                    tongueHit = HitType.COLLECTABLE;
                    // Vibrate their controller
                    player.StartCoroutine(Vibrate());
                    // Play sound for when collectable is stolen
                    player.PlayStolenSound();
                }
            }
            // If the tongue is attached to something then activate it
            line.enabled = tongueHit != HitType.NONE;
        }
    }
Пример #10
0
 // Start is called before the first frame update
 void Start()
 {
     audiosource   = GetComponent <AudioSource>();
     playercontrol = GetComponent <PlayerControllerXbox>();
 }