예제 #1
0
    public bool addNewMissile(GameObject missile,missileType mType)
    {
        switch(mType)
        {
            case(missileType.Homing):
                if(homingMissileObject != null)
                {
                    return false;
                }

                homingMissileObject = missile;
                mC = homingMissileObject.GetComponentInChildren<homingMissileCamera>();
                mC.tLC = this;
                return true;
            case(missileType.Controlled):
                if(controlledMissileOjbect != null)
                {
                    return false;
                }

                controlledMissileOjbect = missile;
                //TODO Arlen:  replace this getcomponent with the correct information
                contMisScript = missile.GetComponentInChildren<ControlledMissile>();
                contMisScript.tLC = this;
                return true;
            default:
            return false;
        }
    }
예제 #2
0
    public bool addNewMissile(GameObject missile, missileType mType)
    {
        switch (mType) {
        case(missileType.Homing):
            if (homingMissileObject != null) {
                return false;
            }

            homingMissileObject = missile;
            navPoint homingNav = homingMissileObject.GetComponentInChildren<navPoint> ();
            homingNav.playerColor = playerColor;
            homingNav.nameTag = nameTag;
            homingNav.refresh();
            mC = homingMissileObject.GetComponentInChildren<homingMissileScript> ();
            mC.tLC = this;
            return true;
        case(missileType.Controlled):
            if (controlledMissileOjbect != null) {
                return false;
            }

            controlledMissileOjbect = missile;
            navPoint contNav = controlledMissileOjbect.GetComponentInChildren<navPoint> ();
            contNav.playerColor = playerColor;
            contNav.nameTag = nameTag;
            contNav.refresh ();
            contMisScript = missile.GetComponentInChildren<ControlledMissile> ();
            contMisScript.tLC = this;
            return true;
        case(missileType.Collector):
            Debug.Log("Received fire command");
            if(ResourceMissile != null) {
                return false;
            }
            Debug.Log("Setting up AI missile");
            ResourceMissile = missile;
            navPoint rescontNav = ResourceMissile.GetComponentInChildren<navPoint>();
            rescontNav.playerColor = playerColor;
            rescontNav.nameTag = nameTag;
            rescontNav.refresh();
            resourceMissileScript = missile.GetComponentInChildren<resourceRobot>();
            resourceMissileScript.tLC = this;
            Debug.Log("Returning true");
            return true;
        case(missileType.DefenseSystem):
            if(DefenseSystem != null){
                return false;
            }
            DefenseSystem = missile;
            DefenseSystemScript = missile.GetComponentInChildren<defensesystem>();
            DefenseSystemScript.tLC = this;
            return true;
        default:
            return false;
        }
    }
예제 #3
0
 void fireMissile(missileType mType)
 {
     int prefabNum = -1;
     GameObject tempMissile;
     if(mType == missileType.Homing)
     {
         prefabNum = 0;
         tempMissile = (GameObject)Instantiate(missilePrefab[prefabNum]);
         if(tLC.addNewMissile(tempMissile,mType))
         {
             tempMissile.transform.rotation = Quaternion.LookRotation(-transform.parent.up,transform.parent.forward);
             tempMissile.transform.position = transform.parent.position;
             homingMissileScript msS = tempMissile.GetComponent<homingMissileScript>();
             msS.init();
         }
         else
         {
             Destroy(tempMissile);
             if(tLC.moveToMissile(0))
             {
                 cleanUpOnExit();
             }
         }
     }
     else if(mType == missileType.Controlled)
     {
         prefabNum = 1;
         tempMissile = (GameObject)Instantiate(missilePrefab[prefabNum]);
         if(tLC.addNewMissile(tempMissile,mType))
         {
             tempMissile.transform.rotation = Quaternion.LookRotation(transform.parent.forward,transform.parent.up);
             tempMissile.transform.position = transform.parent.position;
             ControlledMissile msS = tempMissile.GetComponent<ControlledMissile>();
             msS.init();
         }
         else
         {
             Destroy(tempMissile);
             if(tLC.moveToMissile(1))
             {
                 cleanUpOnExit();
             }
         }
     }
     else if(mType == missileType.Static)
     {
         prefabNum = 2;
     }
     if(missilePrefab.Length <= prefabNum || prefabNum < 0)
     {
         return;
     }
 }