Beispiel #1
0
 private void OnTriggerEnter(Collider other)
 {
     if (other.tag == "People")
     {
         GameObject decale;
         other.GetComponent <HitByShitHandler>().fire();
         decale = instantiateDecale(other.transform.position);
         Vector3 decalePosition = decale.transform.position;
         decale.transform.position = new Vector3(decalePosition.x, decalePosition.y + halfPersonHeight, decalePosition.z);
         foreach (MoveStraight moveStraight in decale.GetComponents <MoveStraight>().Where(moveStraight => moveStraight.getSpeed() == 0))
         {
             moveStraight.setSpeed(1);
         }
     }
     if (other.tag == "CarParts")
     {
         GameObject   decale;
         MoveStraight moveStraight = other.GetComponentInParent <MoveStraight>();
         decale = instantiateDecale(other.transform.position);
         float speed = moveStraight.getSpeed();
         foreach (MoveStraight moveStraightScript in decale.GetComponents <MoveStraight>())
         {
             if (moveStraightScript.getDirection() == Direction.BACK)
             {
                 moveStraightScript.setSpeed(speed);
             }
         }
     }
 }
Beispiel #2
0
    private GameObject instantiateDecale(Vector3 position, Collider other)
    {
        GameObject decale = Instantiate(shitDecale);

        decale.transform.position = position;
        if (other.tag == "CarParts")
        {
            MoveStraight moveStraight = other.GetComponentInParent <MoveStraight>();
            float        speed        = moveStraight.getSpeed();
            foreach (MoveStraight moveStraightScript in decale.GetComponents <MoveStraight>())
            {
                if (moveStraightScript.getDirection() == Direction.BACK)
                {
                    moveStraightScript.setSpeed(speed);
                }
            }
        }
        return(decale);
    }
Beispiel #3
0
    private void OnTriggerEnter(Collider other)
    {
        if (shouldCollide(other.tag))
        {
            MoveStraight moveStraight = other.GetComponent <MoveStraight>();
            GameObject   decale       = null;
            GameObject   decale2      = null;
            GameObject   decale3      = null;
            if (other.tag != "Blocker" && other.tag != "Player" && other.tag != "People" && other.tag != "Shit")
            {
                decale  = instantiateDecale(transform.position, other);
                decale2 = instantiateDecale(calculateVectorWithRandomOffset(transform.position, .5f), other);
                decale3 = instantiateDecale(calculateVectorWithRandomOffset(transform.position, .5f), other);
                decale.transform.Find("Plane").Rotate(0, Random.Range(0, 360), 0);
                decale2.transform.Find("Plane").Rotate(0, Random.Range(0, 360), 0);
                decale3.transform.Find("Plane").Rotate(0, Random.Range(0, 360), 0);
                shouldDestroy = true;
            }
            else if (other.tag == "People")
            {
                other.GetComponent <HitByShitHandler>().fire();
                decale  = instantiateDecale(calculateVectorWithRandomOffset(other.transform.position, 0.5f), other);
                decale2 = instantiateDecale(calculateVectorWithRandomOffset(other.transform.position, 0.5f), other);
                decale3 = instantiateDecale(calculateVectorWithRandomOffset(other.transform.position, 0.5f), other);
                if (other.GetComponent <HitByShitHandler>().getTriggerDeathAnimation())
                {
                    prepareDecaleOnPeople(decale);
                    prepareDecaleOnPeople(decale2);
                    prepareDecaleOnPeople(decale3);
                }

                shouldDestroy = true;
            }
            if (shouldDestroy)
            {
                GameObject.Destroy(gameObject);
            }
        }
    }