Пример #1
0
    void PresentCaught(GameObject thrownObject)
    {
        PresentController presentController = thrownObject.GetComponent <PresentController>();
        PlayerController  throwerController = presentController.GetThrower().GetComponent <PlayerController>();

        if (presentController.IsCaught())
        {
            return;
        }

        //Score
        int multiplier;

        if (!presentController.IsPresent())
        {
            multiplier = throwerController.IncrementScore(scoreValue);
            StartCoroutine("RunBully");
        }
        else
        {
            multiplier = throwerController.IncrementScore(-scoreValue);
            StartCoroutine("StunBully");
        }

        //Save Stat
        GameStats.IncrementStat(GameStats.Stat.BulliesCaught);

        //Show score text
        CreateScoreText(multiplier);
        //Catch new object
        presentController.SetCaught(false);
    }
    void CreateDropItem(bool isPresent)
    {
        //Play throw sound
        PlaySound(throwSound);
        bodyAnimator.SetBool("isThrowing", true);

        //Create Present
        Vector3           initialPosition   = transform.position + new Vector3(8 * transform.localScale.x, -5, 0);
        GameObject        newPresent        = Instantiate(present, initialPosition, Quaternion.identity) as GameObject;
        PresentController presentController = newPresent.GetComponent <PresentController>();

        if (isPresent)
        {
            presentController.SetAsPresent();
        }
        else
        {
            presentController.SetAsCoal();
        }
        presentController.SetThrower(gameObject);
        if (currentCharacter != null)
        {
            presentController.SetPresentSprite(currentCharacter.characterSpriteSheetName);
        }
        presentController.SetSpeed((float)playerAttrs[Attributes.PRESENTSPEED] <= presentSpeed * 3 ? (float)playerAttrs[Attributes.PRESENTSPEED] : presentSpeed * 3);
        canThrow = false;

        //Prevent player from being able to throw immidiately
        StartCoroutine("ThrowCooldown");
    }
Пример #3
0
 public void AddUpPresentValues()
 {
     foreach (GameObject present in presentPool)
     {
         PresentController pc = present.GetComponent <PresentController>();
         GameManager.instance.AddToScore(pc.scoreValue);
     }
 }
Пример #4
0
    IEnumerator AddPresent(GameObject present)
    {
        presentPool.Add(present);
        PresentController pc = present.GetComponent <PresentController>();

        GameManager.instance.AddToWeight(pc.weight);
        GameManager.instance.UpdatePresentCount();
        yield return(new WaitForEndOfFrame());
    }
Пример #5
0
    void PresentCaught(GameObject thrownObject)
    {
        PresentController presentController = thrownObject.GetComponent <PresentController>();
        PlayerController  throwerController = presentController.GetThrower().GetComponent <PlayerController>();

        if (presentController.IsCaught())
        {
            return;
        }

        //Score
        int multiplier;

        if (presentController.IsPresent())
        {
            multiplier = throwerController.IncrementScore(scoreValue);
            PlaySound(presentCatchSound);
            //Powerup
            if (powerup)
            {
                powerup.GetComponent <ApplyPowerupController>().ApplyPowerup(presentController.GetThrower());
            }
            //Run
            RunKid();
        }
        else
        {
            multiplier = throwerController.IncrementScore(-scoreValue);
            PlaySound(coalCatchSound);
            //Run Cry
            CryKid();
        }

        //Save Stat
        GameStats.IncrementStat(GameStats.Stat.KidsCaught);

        //Show score text
        CreateScoreText(multiplier);
        //Hold new object
        HoldObject(thrownObject);
        presentController.SetCaught(true);
    }