示例#1
0
    //init tracked object
    internal void initTrackedObject(Net_OnTrackedObjectInitRequest msg)
    {
        TrackedObject newObj;

        switch (msg.locationData[0])
        {
        case LOCATION_TYPE.SHIP:
            newObj = trackedObjects[msg.locationName];
            Destroy(newObj.obj);
            newObj.obj = Instantiate(sh_shipPrefab);
            trackedObjects[msg.locationName] = newObj;
            break;

        case LOCATION_TYPE.COLONY:
        case LOCATION_TYPE.ASTEROID:
            Debug.Log("Not implemented");
            break;

        case LOCATION_TYPE.NONE:
        default:
            Debug.Log(string.Format("[Sector Scene]: Unexpected SH_Location_Type ({0}).", msg.locationData[0]));
            break;
        }

        if (msg.locationName == activeTrackingLocationName)
        {
            Instantiate(sh_lightRadius, trackedObjects[msg.locationName].obj.transform);
        }
    }
    //send the image and type data of a mobile object
    private void TrackedObjectInitRequest(int connectionID, int recHostID, Net_TrackedObjectInitRequest msg)
    {
        //get type
        //ship
        DB_Ship ship = mdb.FetchShipByName(msg.locationName);

        if (ship != null)
        {
            //generate response
            Net_OnTrackedObjectInitRequest responseMsg = new Net_OnTrackedObjectInitRequest();
            responseMsg.locationName = msg.locationName;
            responseMsg.locationData = new byte[] { LOCATION_TYPE.SHIP, ship.frame, ship.color1, ship.color2, ship.color3 };

            //send response
            SendClient(connectionID, recHostID, responseMsg);
            return;
        }

        //asteroid
        //TODO

        //other
        //TODO
    }