Esempio n. 1
0
    // Use this for initialization
    void Awake()
    {
        // assign player tag
        var rootGo = PartUtil.GetRootGo(gameObject);

        if (rootGo != null)
        {
            rootGo.tag = "enemy";
        }
    }
Esempio n. 2
0
    public static GameRecordEvent GetEventChannel(
        GameObject gameObject
        )
    {
        var rootGo = PartUtil.GetRootGo(gameObject);

        if (rootGo != null)
        {
            var botComp = rootGo.GetComponent <BotBuilder>();
            if (botComp != null)
            {
                return(botComp.eventChannel);
            }
        }
        return(null);
    }
 void OnCollisionEnter(Collision coll)
 {
     if (spinPower > 0f)
     {
         // apply collision force if we hit a rigidbody
         var rbColl = coll.rigidbody;
         if (rbColl != null)
         {
             // don't apply collision force to self
             if (PartUtil.GetRootGo(gameObject) != PartUtil.GetRootGo(coll.gameObject))
             {
                 var f = (-transform.right) * throwForceLateral * spinPower + transform.up * throwForceUpward * spinPower;
                 //Debug.Log("applying f: " + f + " to " + rbColl.gameObject.name);
                 rbColl.AddForceAtPosition(f, coll.contacts[0].point);
             }
         }
     }
 }
 void Start()
 {
     rootGo = PartUtil.GetRootGo(gameObject);
     health = GetComponent <Health>();
     if (health == null)
     {
         health = PartUtil.GetComponentInParentBody <Health>(gameObject);
     }
     // enforce max damage > min damage
     if (maxDamage < minDamage)
     {
         maxDamage = minDamage;
     }
     if (emitScrews)
     {
         screwBurstPrefab = (GameObject)Resources.Load("ScrewBurst");
     }
 }
 void OnCollisionEnter(Collision coll)
 {
     if (power > 0f && impactForce > 0f)
     {
         // apply collision force if we hit a rigidbody
         var rbColl = coll.rigidbody;
         if (rbColl != null)
         {
             // don't apply collision force to self
             if (PartUtil.GetRootGo(gameObject) != PartUtil.GetRootGo(coll.gameObject))
             {
                 var f = -coll.contacts[0].normal * impactForce * power;
                 if (debug)
                 {
                     Debug.Log("Flipper Collision" +
                               "\napplying f: " + f + "(" + f.magnitude + ")" +
                               "\npower: " + power +
                               "\ncollided with: " + rbColl.gameObject.name);
                 }
                 rbColl.AddForceAtPosition(f, coll.contacts[0].point);
             }
         }
     }
 }
Esempio n. 6
0
 void Start()
 {
     rb     = GetComponent <Rigidbody>();
     rootGo = PartUtil.GetRootGo(gameObject);
 }