コード例 #1
0
    void Update()
    {
        timeToLive -= Time.deltaTime;

        if (timeToLive <= 0)
        {
            if (raycastHit != null)
            {
                if (!TeamHelper.IsSameTeam(gameObject.layer, raycastHit.layer))
                {
                    Vector3 impactPoint = raycastHit.transform.position - ProjectileController.FlyControl.VelocityDirection;
                    switch (raycastHit.tag)
                    {
                    case "Player":
                        raycastHit.GetComponent <HealthControl>().TakeDamage(ProjectileController.Damage, impactPoint);
                        break;

                    case "Npc":
                        raycastHit.GetComponent <HealthControl>().TakeDamage(ProjectileController.Damage, impactPoint);
                        break;

                    case "Mothership":
                        raycastHit.GetComponent <HealthControl>().TakeDamage(ProjectileController.Damage, impactPoint);
                        break;
                    }
                }
            }

            Destroy(gameObject);
        }
    }
コード例 #2
0
ファイル: DroneSpawn.cs プロジェクト: Game-Group/dog-fighter
    // Spawn drones from each start location to each destination location
    void SpawnDrones()
    {
        //FIXME: This is an ugly fix for not spawning on each other
        Vector3 space = new Vector3(0, 0, 70);

        for (int j = 0; j < drones_per_location; j++)
        {
            for (int i = 0; i < spawn_locations.Length; i++)
            {
                GameObject droneInstance = (GameObject)Instantiate(drone, spawn_locations[i].position + (space * j), spawn_locations[i].rotation);
                droneInstance.tag = "Npc";
                if (TeamHelper.IsSameTeam(gameObject.layer, 8))
                {
                    droneInstance.layer = 8;
                }
                else
                {
                    droneInstance.layer = 11;
                }

                // Propagate layer
                TeamHelper.PropagateLayer(droneInstance, droneInstance.layer);
                GameObject triggerObject = droneInstance.transform.FindChild("Trigger").gameObject;
                triggerObject.layer = 3;

                droneInstance.GetComponent <GunSwitcher>().LayerChanged();

                DroneBehaviour behav = droneInstance.GetComponent <DroneBehaviour>();
                behav.target = destination[i];

                this.networkSyncDroneSpawn(droneInstance);
            }
        }
    }
コード例 #3
0
    private void HandleProjectileCollision(Collision info)
    {
        //if (Network.peerType == NetworkPeerType.Server || GlobalSettings.SinglePlayer)
        {
            //Debug.Log("Collision detected.");
            //Debug.Log(info.gameObject.name);

            if (!TeamHelper.IsSameTeam(info.collider.gameObject.tag, gameObject.layer))
            {
                HealthControl.TakeDamage(info.gameObject.GetComponent <ProjectileController>().Damage, info.contacts[0].point);
            }
        }

        Destroy(info.gameObject);
    }
コード例 #4
0
 void OnTriggerEnter(Collider Obj)
 {
     // Check if this is a drone
     if (Obj.gameObject.tag == "Npc")
     {
         DroneBehaviour s = Obj.gameObject.GetComponent <DroneBehaviour>();
         GameObject     p = ships[0];
         if (TeamHelper.IsSameTeam(int.Parse(p.layer.ToString()), int.Parse(Obj.gameObject.layer.ToString())))
         {
             Transform newTarget = ships[1].transform.FindChild("DroneDestination");
             s.target = newTarget;
         }
         else
         {
             Transform newTarget = ships[0].transform.FindChild("DroneDestination");
             s.target = newTarget;
         }
     }
 }