Ejemplo n.º 1
0
    void OnReceive(NetworkPacket pack, string id)
    {
        if (pack.Header == PacketType.ArtilleryTankPack)
        {
            ArtilleryTankPack packet = (ArtilleryTankPack)pack;

            if (packet.ArtilleryID == this.networkID)
            {
                toHandle = packet;

                wave_control.Instance.toReactivate.Enqueue(gameObject);
            }
        }
    }
Ejemplo n.º 2
0
    public override void Update()
    {
        base.Update();

        if (GetComponent <Root>().HP > 0)
        {
            lastpos = transform.position;
        }
        if (isroaming)
        {
            warningobj.SetActive(false);
        }
        else
        {
            warningobj.SetActive(true);
        }

        warningobj.transform.position = droplocation; //reticle warning UI

        artillery_tank_attack();                      //from parent

        if (toHandle != null)
        {
            droplocation   = toHandle.DropLocation;
            wanderlocation = toHandle.WanderLocation;

            agent.enabled      = false;
            transform.position = toHandle.CurrentPosition;
            agent.enabled      = true;
            agent.nextPosition = toHandle.CurrentPosition;

            agent.SetDestination(wanderlocation);

            toHandle      = null;
            lastUpdate    = DateTime.Now;
            hasSentPacket = false;
        }

        if (Network.IsHost && (DateTime.Now - lastSync).TotalMilliseconds > Network.UpdateInterval)
        {
            ArtilleryTankPack pack = new ArtilleryTankPack(droplocation, wanderlocation, networkID, transform.position);
            Network.Send(pack);

            lastSync      = DateTime.Now;
            hasSentPacket = false;
        }
    }