Ejemplo n.º 1
0
    IEnumerator AddEverySecondEditor()
    {
        for (int i = 0; i < addNumberOfShipsTest; i++)
        {
            GameObject go = Instantiate(AIPrefab);
            Destroy(go.GetComponent <AIShipController>());


            Ship ship = go.GetComponent <Ship>();
            ship.myFleet = this;
            ship.LeaveFleet();
            int index = AddShip(ship);

            Vector3 newPos = ShipTargetPositionLocator.GetShipTargetPosition(index + 1);

            Transform t = new GameObject().transform;
            t.parent               = transform;
            t.localPosition        = newPos;
            ship.controller.target = t;

            ship.transform.position = transform.TransformPoint(newPos);

            ship.SetAnimTrigger("ShipSpawn");
            yield return(new WaitForSeconds(0.5f));
        }
    }
Ejemplo n.º 2
0
    public void CalculateRadius()
    {
        int indexOfLastLivingShip = 1;

        for (int i = myFleet.ships.Count - 1; i >= 0; --i)
        {
            if (myFleet.ships[i] != null)
            {
                indexOfLastLivingShip = i;
                break;
            }
        }

        Vector3 midpoint = Vector3.zero;

        midpoint.z = ShipTargetPositionLocator.GetShipTargetPosition(indexOfLastLivingShip).z * 0.75f;
        transform.localPosition = midpoint;

        int lastRow = TriangleNumbers.GetRowInTriangle(indexOfLastLivingShip);

        // ********************************************************************************
        // DON'T DELETE - TOOK AGES TO FIGURE OUT *****************************************
        // ********************************************************************************
        //int lastRowStart = TriangleNumbers.GetTriangleNumber(lastRow - 1) + 1;
        //int lastRowCount = TriangleNumbers.GetCountInRow(lastRow);

        //Vector3 leftMost = ShipTargetPositionLocator.GetShipTargetPosition(lastRowStart);
        //Vector3 rightMost = ShipTargetPositionLocator.GetShipTargetPosition(lastRowStart + lastRowCount -1);

        //float lastRowWidth = Vector3.Distance(leftMost, rightMost);
        trigger.radius = ShipTargetPositionLocator.GAPSIZE * (lastRow + 1) * 0.5f;
        //Debug.Log($"Detection Sphere radius is now: {trigger.radius}");
    }
Ejemplo n.º 3
0
    public void Respawn()
    {
        if (myFleet == null)
        {
            Destroy(gameObject); return;
        }

        int index = myFleet.AddShip(this);

        Vector3 newPos = ShipTargetPositionLocator.GetShipTargetPosition(index + 1);

        Transform t = new GameObject().transform;

        t.parent          = myFleet.transform;
        t.localPosition   = newPos;
        controller.target = t;

        transform.position = myFleet.transform.TransformPoint(newPos);

        SetAnimTrigger("ShipSpawn");
        health = maxHealth;
    }
Ejemplo n.º 4
0
 // Start is called before the first frame update
 void Start()
 {
     playerShip.transform.localPosition = ShipTargetPositionLocator.GetShipTargetPosition(1, 1);
     ships.Add(playerShip);
 }
Ejemplo n.º 5
0
 GameObject CreateShip(int row, int posInRow) => CreateShip(ShipTargetPositionLocator.GetShipTargetPosition(row, posInRow));