Exemplo n.º 1
0
 async Task IHandle <EntityMove> .Handle(EntityMove message)
 {
     await SendMovePacket(AttachedObject.GetComponent <ChunkEventBroadcastComponent>().GetGenerator());
 }
Exemplo n.º 2
0
 public int __decode(byte[] binData, ref int pos)
 {
     this.moveInfo = new EntityMove();
     this.moveInfo.__decode(binData, ref pos);
     return(pos);
 }
Exemplo n.º 3
0
 public MoveNotice(EntityMove moveInfo)
 {
     this.moveInfo = moveInfo;
 }
Exemplo n.º 4
0
 public MoveNotice()
 {
     moveInfo = new EntityMove();
 }
Exemplo n.º 5
0
 public BucketChangeResult(EntityLocation newLocation, EntityMove swap)
 => (NewLocation, Swap) = (newLocation, swap);
Exemplo n.º 6
0
    private void Spawn()
    {
        // Reset the spawn timer.
        nextSpawnTime = Time.time + Random.Range(5, spawnDelay);
        // Select eligible rows from the nearest ones (road or water).
        List <Row> goodRows = new List <Row>();

        for (int r = currRow; r < currRow + 3 && r < rows; r++)
        {
            if ((r % 10 >= 0 && r % 10 < 2) || (r % 10 == 5))
            {
                continue;   // Grass row.
            }
            else if (r % 10 >= 2 && r % 10 < 5)
            {
                goodRows.Add(new Row(r, 'a'));
            }
            else
            {
                goodRows.Add(new Row(r, 'w'));
            }
        }
        if (goodRows.Count == 0)
        {
            return;
        }
        // Randomly choose one of them.
        int randInt   = Random.Range(0, goodRows.Count - 1);
        Row randomRow = goodRows[randInt];

        goodRows.RemoveAt(randInt);
        // For variety, trucks will come from the left and logs from the right.
        var        spawnPos = new Vector3(0, cellWidth * .5f + cellWidth * randomRow.number, -.4f);
        var        displacement = entitySpeed * cellWidth;
        GameObject entity, entity2 = null;

        if (randomRow.type == 'w')
        {
            spawnPos.x   = Screen.width;
            displacement = displacement * (-1);
            // Spawn the entity and adjust its properties.
            entity = Instantiate(logPrefab, this.transform);
            entity.transform.position = spawnPos;
            if (goodRows.Count > 0)
            {
                randomRow = goodRows[Random.Range(0, goodRows.Count - 1)];
                spawnPos  = new Vector3(Screen.width, cellWidth * .5f + cellWidth * randomRow.number, -.4f);
                entity2   = Instantiate(logPrefab, this.transform);
                entity2.transform.position = spawnPos;
            }
        }
        else
        {
            entity = Instantiate(truckPrefab, this.transform);
            entity.transform.position = spawnPos;
        }


        entity.transform.localScale = new Vector3(cellWidth, cellWidth, 1);
        EntityMove em = entity.AddComponent <EntityMove>();

        em.velocity = displacement;
        if (entity2 != null)
        {
            entity2.transform.localScale = new Vector3(cellWidth, cellWidth, 1);
            EntityMove em2 = entity2.AddComponent <EntityMove>();
            em2.velocity = displacement;
        }
    }