//serve per contollare i limiti del movimento sull'asse y void Update() { //contollo del movimento su e giù e della rotazione this.transform.Rotate(0, 0.2f, 0); if (this.transform.position.y < 3 && up) { this.transform.position = new Vector3(this.transform.position.x, this.transform.position.y + 0.5f * Time.deltaTime, this.transform.position.z); } else if (this.transform.position.y > 2 && !up) { this.transform.position = new Vector3(this.transform.position.x, this.transform.position.y - 0.5f * Time.deltaTime, this.transform.position.z); } if (this.transform.position.y <= 2 && !up) { up = true; } else if (this.transform.position.y >= 3 && up) { up = false; } //se viene abilitata, istanzia l'oggetto nella mano del player e si distrugge if (enable) { PlayerObjectController.takeObject(this.gameObject, (GameObject)Resources.Load("TorchPiked(Clone)", typeof(GameObject)), "TorchImage"); victoryCheck.torchPicked++; enable = false; } }
public static void DoHandle(NetDataRequest data, ClientController client, string networkID) { client.Actualy = true; List <ClientController> clients = new List <ClientController>(Server.ClientControllers); clients.Remove(client); clients.RemoveAll(x => !x.Actualy); List <ClientController> actualyClients = new List <ClientController>(Server.ClientControllers); actualyClients.RemoveAll(x => !x.Actualy); string id = (string)data.Values["id"].ObjectValue; RoomController clientRoom = Server.GetClientRoom(client); client.Client.ID = id; client.SetMissionController(MissionDispenser.GetMission(clientRoom.Room.ID, clientRoom.Room.MissionName)); PlayerObject player = new PlayerObject(new Vector3K(0f, 0f, 0f), new Vector3K(0f, 0f, 0f), new Vector3K(2f, 2f, 2f), new Vector3K(0f, 0f, 0f)); player.OwnerID = client.Client.ID; PlayerObjectController playerController = ObjectFactory.GetObject(player) as PlayerObjectController; client.MissionController.AddDynamicObject(playerController); client.ControlledObjects.Add(player.ID, playerController); NetDataRequest response = new NetDataRequest(RequestTypes.EnterInMission, new Dictionary <string, ObjectWrapper>() { { "id", new ObjectWrapper <string>(id) } }); Server.SendResponse(client, Utils.ToBytesJSON(response), networkID); }
// Update is called once per frame void Update() { this.transform.Rotate(0, 0.2f, 0); if (this.transform.position.y < 2 && up) { this.transform.position = new Vector3(this.transform.position.x, this.transform.position.y + 0.5f * Time.deltaTime, this.transform.position.z); } else if (this.transform.position.y > 1 && !up) { this.transform.position = new Vector3(this.transform.position.x, this.transform.position.y - 0.5f * Time.deltaTime, this.transform.position.z); } if (this.transform.position.y <= 1 && !up) { up = true; } else if (this.transform.position.y >= 2 && up) { up = false; } if (enable) { if (Input.GetButtonDown("Fire1")) { Debug.Log("rilevo collisione con :" + this.gameObject.name); PlayerObjectController.takeObject(this.gameObject, (GameObject)Resources.Load("HammerPicked", typeof(GameObject)), "HammerImage"); victoryCheck.hammerPicked++; enable = false; } } }