public static string Create(string id, CharacterAnimType animType, Vector3 position, Quaternion rotation, Vector3 forwards, bool isServer) { characterPrefab = (GameObject) Resources.Load ("Prefabs/Girl"); GameObject character = GameObject.Instantiate (characterPrefab); character.transform.position = new Vector3 (position.x, position.y, position.z); character.transform.rotation = Quaternion.Euler (rotation.x, rotation.y, rotation.z); character.name = id; character.transform.forward = forwards; if (isServer) { character.AddComponent<CharacterUpdaterServer> (); } else { character.AddComponent<CharacterUpdater> (); } CharacterUpdater updater = character.GetComponent<CharacterUpdater> (); if (updater) updater.UpdateAnim(animType); return id; }
public void UpdateAnim(CharacterAnimType type) { animType = type; }
public static void UpdateCharacterObject(string id, CharacterAnimType animType, Vector3 position, Quaternion rotation, Vector3 forward, float Speed, bool Hit, bool Jump) { GameObject obj = GameObject.Find (id); if (obj) { obj.transform.position = position; obj.transform.rotation = rotation; obj.transform.forward = forward; CharacterUpdater animUpdater = obj.GetComponent<CharacterUpdater> (); animUpdater.UpdateAnim (animType); animUpdater.UpdateParameters (Speed, Hit, Jump); } else { CharacterSpawner.Create (id, animType, position, rotation, forward,Networking.IsServer); } }
public static void SendCharacterObject(string id, CharacterAnimType animType, Vector3 position, Quaternion rotation, Vector3 forward, float Speed, bool Hit, bool Jump) { SFSObject message = new SFSObject (); message.PutUtfString ("messageType", "UpdatePosition"); message.PutUtfString ("objectType", "Character"); message.PutInt ("charAnim", (int)animType); message.PutFloat ("xPos", position.x); message.PutFloat ("yPos", position.y); message.PutFloat ("zPos", position.z); message.PutFloat ("xRot", rotation.x); message.PutFloat ("yRot", rotation.y); message.PutFloat ("zRot", rotation.z); message.PutFloat ("xDir", forward.x); message.PutFloat ("yDir", forward.y); message.PutFloat ("zDir", forward.z); message.PutFloat ("Speed", Speed); message.PutBool ("Hit", Hit); message.PutBool ("Jump", Jump); message.PutUtfString ("ID", id); Networking.SendData (message); }