Exemplo n.º 1
0
    public void generateFiringArc(GameObject target, FiringArc arc)
    {
        GameObject canvas    = target.transform.Find("Canvas").gameObject;
        GameObject firingArc = canvas.transform.Find("FiringArc").gameObject;
        float      angle     = arc.rightBoundary - arc.leftBoundary;

        canvas.transform.localPosition = new Vector3(0.0f, 0.002f, 0.0f);
        firingArc.GetComponent <Image>().fillOrigin = (int)Image.Origin360.Top;
        firingArc.GetComponent <Image>().fillAmount = angle / 360.0f;
        firingArc.transform.Rotate(0.0f, 0.0f, angle / 2, Space.Self);
    }
Exemplo n.º 2
0
    public void instantiateShips()
    {
        foreach (Player player in MatchDatas.getPlayers())
        {
            int     loopIndex        = 0;
            Vector3 startingPosition = MatchHandlerUtil.getShipCollectionHolderPosition(player.getPlayerID());

            foreach (LoadedShip loadedShip in player.getSquadron())
            {
                Ship       ship             = loadedShip.getShip();
                string     shipType         = ship.ShipId;
                GameObject shipHolderPrefab = (GameObject)Resources.Load(MatchHandlerConstants.PREFABS_FOLDER + "/SmallShipContainerPrefab", typeof(GameObject));
                GameObject shipPrefab       = (GameObject)Resources.Load(MatchHandlerConstants.PREFABS_FOLDER + "/" + shipType, typeof(GameObject));

                //TODO Tweak these coordinates!
                float posX = startingPosition.x + (loopIndex * MatchHandlerConstants.offsetX);
                float posY = startingPosition.y;
                float posZ = startingPosition.z;

                GameObject shipHolderGameObject = (GameObject)GameObject.Instantiate(
                    shipHolderPrefab,
                    new Vector3(posX, posY, posZ),
                    Quaternion.identity
                    );

                // TODO change models, so offset is not needed anymore!
                Vector3 shipOffset = new Vector3(2.81896f * 500.0f, 0.0f, 3.286796f * 500.0f);

                GameObject shipGameObject = (GameObject)GameObject.Instantiate(
                    shipPrefab,
                    shipHolderGameObject.GetComponent <Renderer>().bounds.center + shipOffset,
                    Quaternion.identity
                    );

                shipGameObject.transform.SetParent(shipHolderGameObject.transform, true);

                shipHolderGameObject.GetComponent <ShipProperties>().setLoadedShip(loadedShip);

                /***********************************/
                FiringArc arc = new FiringArc();
                arc.leftBoundary  = -45.0f;
                arc.rightBoundary = 45.0f;
                /***********************************/

                generateFiringArc(shipHolderGameObject, arc);

                loopIndex++;
            }
            ;
        }
    }