Пример #1
0
 void OnCollisionEnter(Collision other)
 {
     if (other.gameObject.name == "BallOfFire(Clone)")   // checks if the tree gets hit be lars's ball
     {
         BossHP -= BallOfFire.GetBallDmg();              // if the tree gets hit it will lose HP arcording to how close lars is to the tree
     }
 }
    void OnCollisionEnter(Collision other)
    {
        if (other.gameObject.name == "BallOfFire(Clone)")
        {
            GetHit(BallOfFire.GetBallDmg());                    // When the Ball of Fire hits an apple it will get hit with the ball's damage
            print(AppleGREEN.GetHP() + " " + AppleRed.GetHP() + " " + AppleYELLOW.GetHP() + " " + Lars.GetHeroHP());
        }

        if (other.gameObject.name == "Lars")
        {
            for (float i = 0f; i < 5f; i += 0.1f)               //making the Apple jump y=5 up sort of slowly when touched by lars, giving him time to get away
            {
                transform.position += new Vector3(0, i, 0) * Time.deltaTime;
            }
        }
    }
Пример #3
0
    void spawnBallOfFire()
    {
        Vector3 startPosition = gameObject.transform.GetChild(3).gameObject.transform.position;

        startPosition.z = prefabBallOfFire.transform.position.z;
        GameObject ballOfFire = (GameObject)Instantiate(prefabBallOfFire);

        ballOfFire.transform.position = startPosition;
        BallOfFire scriptBallOfFire = ballOfFire.GetComponent <BallOfFire>();

        scriptBallOfFire.speedForBallOfFire = speedOfBall;
        scriptBallOfFire.damageOfFire       = damageOfFire;
        scriptBallOfFire.distance           = distanceForBallOfFire;
        scriptBallOfFire.timeForEndFire     = timeForEndFire;
        scriptBallOfFire.ticksOfFire        = ticksOfFire;
        scriptBallOfFire.directionPlayer    = GetComponent <PlayerAnimation>().getDirection();
    }