コード例 #1
0
    void UpdateOrbitalPosition()
    {
        CurrentPositionAngle += ((20 - OrbitHeight) / 2f) * Time.deltaTime * dir;
        transform.position    = OrbitRenderer.GetPoint(OrbitHeight, CurrentPositionAngle);
        int mod = dir > 0 ? -1 : 1;

        transform.up = mod * new Vector3(transform.position.y, -1 * transform.position.x, 0).normalized;
        //sprite.transform.rotation =  (transform.position - GameManager.Instance.Planet.transform.position)
    }
コード例 #2
0
    void Start()
    {
        GameManager.OnGameOver += onGameOver;
        path = OrbitRenderer.GetPoints(OrbitHeight, pathPrecision);
        TaskWeights.Add(ShipTask.Scanning, 0.5f);
        TaskWeights.Add(ShipTask.Repairs, 0f);
        TaskWeights.Add(ShipTask.Fighting, 0f);
        TaskWeights.Add(ShipTask.Resting, 0f);
        CurrentPositionAngle = OrbitInsertionAngle;
        OrbitInsertionPoint  = OrbitRenderer.GetPoint(OrbitHeight, OrbitInsertionAngle);

        dir = Random.Range(0f, 1f) < 0.5f ? 1 : -1;
        //if (dir > 0) gameObject.transform.localScale = new Vector3(1, -1, 1);
        sprite.color = new Color(sprite.color.r, sprite.color.g, sprite.color.b, 0f);
        minDelta     = Random.Range(0.2f, 0.8f);
    }
コード例 #3
0
    public void GenerateShip()
    {
        ShipCount++;
        int        type    = Random.Range(0, 4);
        float      angle   = (float)Random.Range(0, 359);
        float      radius  = (float)Random.Range(8, 15);
        GameObject newShip = Instantiate(ShipPrefab, GameRoot.transform);

        newShip.name = RandomName();
        ShipController newShipController = newShip.GetComponent <ShipController>();

        newShipController.OrbitHeight         = radius;
        newShipController.ShipName            = newShip.name;
        newShip.transform.position            = OrbitRenderer.GetPoint(radius, angle).normalized * 50f;
        newShipController.OrbitInsertionAngle = angle;

        newShipController.ShipType = type;

        switch (type)
        {
        case 0:
            newShip.GetComponentInChildren <SpriteRenderer>().color = ScienceShipColor;
            Debug.Log("Ship" + type + " " + newShip.GetComponentInChildren <SpriteRenderer>().color);

            newShipController.IntelMod = 1.5f;
            newShipController.FightMod = 0.5f;
            newShipController.ShipType = type;
            break;

        case 1:
            newShip.GetComponentInChildren <SpriteRenderer>().color = EngineerColor;
            Debug.Log("Ship" + type + " " + newShip.GetComponentInChildren <SpriteRenderer>().color);

            newShipController.RepairMod  = 1.5f;
            newShipController.DespairMod = 0.5f;
            newShipController.ShipType   = type;

            break;

        case 2:
            newShip.GetComponentInChildren <SpriteRenderer>().color = MilitaryColor;
            Debug.Log("Ship" + type + " " + newShip.GetComponentInChildren <SpriteRenderer>().color);

            newShipController.FightMod   = 1.5f;
            newShipController.DespairMod = 0.5f;
            newShipController.ShipType   = type;

            break;

        case 3:
            newShip.GetComponentInChildren <SpriteRenderer>().color = PassengerColor;
            Debug.Log("Ship" + type + " " + newShip.GetComponentInChildren <SpriteRenderer>().color);

            newShipController.FightMod   = 0.5f;
            newShipController.DespairMod = 1.5f;
            newShipController.ShipType   = type;

            break;
        }


        GameObject newOverlay = Instantiate(OverlayPrefab, OverlayParent.transform);

        newOverlay.GetComponent <ShipUIOverlay>().LinkedShip = newShipController;
        newOverlay.name = newShipController.ShipName + "_overlay";

        newShipController.SetOverlay(newOverlay);
        newShipController.timerCircle = newOverlay.GetComponent <ShipUIOverlay>().TimerMask.gameObject;
    }