void OnReceive(NetworkPacket pack, string id) { if (pack.Header == PacketType.AITankPack) { AITankPack packet = (AITankPack)pack; if (packet.TankID == this.networkID) { this.toHandle = packet; wave_control.Instance.toReactivate.Enqueue(gameObject); } } }
public override void Update() { base.Update(); if (execute) { if (GetComponent <Root>().HP > 0) { lastpos = transform.position; } buggy_attack_target(); //from parent } if (toHandle != null) { agent.enabled = false; transform.position = toHandle.Position; agent.enabled = true; agent.nextPosition = toHandle.Position; wanderlocation = toHandle.RandomOffsetPosition; if (readytoroam) { agent.SetDestination(wanderlocation); } else { agent.SetDestination(bastion.transform.position); } toHandle = null; lastUpdate = DateTime.Now; hasSentPacket = false; } if (Network.IsHost && (DateTime.Now - lastSync).TotalMilliseconds > Network.UpdateInterval) { AITankPack pack = new AITankPack(transform.position, networkID, wanderlocation); Network.Send(pack); lastSync = DateTime.Now; hasSentPacket = false; } }