private void DestroyMissiles(Vector3 pos, CellStateContainer cell)
    {
        pos.y += 1f;

        if (Physics.CheckSphere(pos, 1f, 1 << 10))
        {
            var colliders = Physics.OverlapSphere(pos, 1f, 1 << 10);
            if (colliders.Length > 0)
            {
                Destroy(colliders[0].gameObject);
            }
        }
    }
    private void DestroyBuilding(Vector3 pos, CellStateContainer cell)
    {
        if (Physics.CheckSphere(pos, 1f, 1 << 9))
        {
            var colliders = Physics.OverlapSphere(pos, 1f, 1 << 9);

            if (colliders.Length > 0)
            {
                Destroy(colliders[0].gameObject);
                var go = Instantiate(explosionPrefab, pos, Quaternion.identity);
                go.transform.SetParent(transform);
                Destroy(go, 2f);
            }
        }
    }
    private void CreateMissiles(Vector3 pos, CellStateContainer cell)
    {
        pos.y += 1f;

        if (!Physics.CheckSphere(pos, 1f, 1 << 10))
        {
            var go = Instantiate(missilePrefab, pos, Quaternion.identity);

            if (cell.Missiles[0].PlayerType == StarterBot.Enums.PlayerType.A)
            {
                go.transform.rotation = Quaternion.Euler(0f, 90f, 0f);
            }
            else
            {
                go.transform.rotation = Quaternion.Euler(0f, -90f, 0f);
            }

            go.transform.SetParent(transform);
        }
    }
示例#4
0
 public static bool IsValidCell(CellStateContainer targetCell)
 {
     return(targetCell.Type != CellType.DEEP_SPACE && targetCell.Type != CellType.DIRT);
 }
    private void CreateBuilding(Vector3 pos, CellStateContainer cell)
    {
        var playSound = true;

        if (Physics.CheckSphere(pos, 1f, 1 << 9))
        {
            var colliders = Physics.OverlapSphere(pos, 1f, 1 << 9);

            if (colliders.Length > 0)
            {
                var previous = colliders[0].gameObject;
                if (previous.transform.localScale != Vector3.one)
                {
                    playSound = false;
                    Destroy(previous);
                }
                else
                {
                    return;
                }
            }
            else
            {
                return;
            }
        }

        var type = cell.Buildings[0].BuildingType;

        GameObject prefab = null;

        if (type == StarterBot.Enums.BuildingType.Attack)
        {
            prefab = attackPrefab;
        }
        else if (type == StarterBot.Enums.BuildingType.Defense)
        {
            prefab = defendPrefab;
        }
        else if (type == StarterBot.Enums.BuildingType.Energy)
        {
            prefab = energyPrefab;
        }
        else if (type == StarterBot.Enums.BuildingType.Tesla)
        {
            prefab = teslaPrefab;
        }

        var go = Instantiate(prefab, pos, Quaternion.identity);

        go.transform.SetParent(transform);

        if (cell.Buildings[0].ConstructionTimeLeft > -1)
        {
            go.transform.localScale = new Vector3(0.5f, 0.5f, 0.5f);
        }
        else
        {
            go.GetComponent <AudioSource>().Stop();
        }
    }