コード例 #1
0
    public void TakeDamage()
    {
        if (immunityRemaining == 0)
        {
            immunityRemaining = DAMAGE_IMMUNITY_TIME;
            --health;
        }

        if (health == 0)
        {
            var shipScript = Utility.GetShipScript();
            var graph      = shipScript.GetShipGraph();

            // cannot iterate over list when it is being modified; must copy the objects into separate list
            var attachedObjects = new List <GameObject>(graph[gameObject]);
            foreach (GameObject attachedObject in attachedObjects)
            {
                JointScript.Detach(gameObject, attachedObject);
                shipScript.RemoveConnection(gameObject, attachedObject);
            }
        }
    }
コード例 #2
0
ファイル: collisionJointer.cs プロジェクト: TeamNewton/Game
 void OnCollisionEnter(Collision coll)
 {
     Debug.Log("Colliding!");
     JointScript.Attach(this.gameObject, coll.gameObject);
     JointScript.Detach(this.gameObject, coll.gameObject);
 }