Exemplo n.º 1
0
    public void GetData(LoadableObject target)
    {
        objectId = target.objectId;

        sceneId = SceneManager.GetActiveScene().buildIndex;

        savePos      = target.savePos;
        saveRot      = target.saveRot;
        hasRigidbody = target.hasRigidbody;

        if (savePos)
        {
            posX = target.gameObject.transform.position.x;
            posY = target.gameObject.transform.position.y;
            posZ = target.gameObject.transform.position.z;
        }

        if (saveRot)
        {
            rotX = target.gameObject.transform.localEulerAngles.x;
            rotY = target.gameObject.transform.localEulerAngles.y;
            rotZ = target.gameObject.transform.localEulerAngles.z;
        }

        if (hasRigidbody)
        {
            velX = target.gameObject.GetComponent <Rigidbody>().velocity.x;
            velY = target.gameObject.GetComponent <Rigidbody>().velocity.y;
            velZ = target.gameObject.GetComponent <Rigidbody>().velocity.z;
        }
    }
Exemplo n.º 2
0
 public override bool PlaceObject(LoadableObject _object)
 {
     if (this.Object == null)
     {
         this.Object = _object;
         this.SetSymbol();
         this.Object.CurrentPlace = this;
         GiveLoadToShip();
         return(true);
     }
     else
     {
         return(false);
     }
 }
Exemplo n.º 3
0
        public SerializedPlayerAndTrain(GameObject playerTrain, Player player)
        {
            this.player = player;
            LoadableObject parentObj = new LoadableObject();

            parentObj.pathInResource = playerTrain.GetComponent <ResourceLoadableObj>().Path;
            parentObj.position       = playerTrain.transform.position;
            parentObj.rotation       = playerTrain.transform.rotation;
            objects.Add(parentObj);
            List <GameObject>          initList = new List <GameObject>();
            List <ResourceLoadableObj> trainScriptsToSerialize = GetAllObjectsOfTypeInChildren <ResourceLoadableObj>(playerTrain);

            foreach (var script in trainScriptsToSerialize)
            {
                LoadableObject objectToSerialize = new LoadableObject();
                objectToSerialize.pathInResource = script.Path;
                objectToSerialize.position       = script.gameObject.transform.position;
                objectToSerialize.rotation       = script.gameObject.transform.rotation;
                objects.Add(objectToSerialize);
                Debug.Log($"{objectToSerialize.pathInResource}");
            }
        }