Ejemplo n.º 1
0
    void Start()
    {
        cl = GetComponent <Collider> ();
        unitAgent parent = GetComponentInParent <unitAgent> ();

        Destroy(gameObject, destroyTimer);
    }
Ejemplo n.º 2
0
    void groupSelection(Vector2 RectStart, Vector2 RectEnd, GameObject selected, int Type)
    {
        currentSelection.Clear();
        if (debugActive)
        {
            Debug.Log("GROUP SELECT CALLED");
        }

        Rect aimRect = new Rect(Mathf.Min(RectEnd.x, RectStart.x), Mathf.Min(RectEnd.y, RectStart.y), Mathf.Abs(RectEnd.x - RectStart.x), Mathf.Abs(RectEnd.y - RectStart.y));


        foreach (GameObject Unit in unitsInPlay)
        {
            if (Unit != null)
            {
                Vector3 pos = Camera.main.WorldToScreenPoint(Unit.transform.position);
                //pos.y = Screen.height - pos.y;

                if (aimRect.Contains(pos))
                {
                    unitAgent logic = Unit.GetComponent <unitAgent> ();
                    if (logic.playerID == playerID)
                    {
                        currentSelection.Add(Unit);
                    }
                }
            }
        }
        if (debugActive)
        {
            Debug.Log("Units Selected");
        }
        setUnitSelects();
    }
Ejemplo n.º 3
0
 // Use this for initialization
 void Start()
 {
     if (unitmgmt == null)
     {
         unitmgmt = GetComponentInParent <unitAgent> ();
     }
 }
Ejemplo n.º 4
0
    void typeSelection(string type)
    {
        currentSelection.Clear();
        if (debugActive)
        {
            Debug.Log("Type SELECT CALLED");
        }

        Rect screenRect = new
                          Rect(0, 0, Screen.width, Screen.height);

        foreach (GameObject Unit in unitsInPlay)
        {
            Vector3   pos    = Camera.main.WorldToScreenPoint(Unit.transform.position);
            unitAgent mgmt   = Unit.GetComponent <unitAgent> ();
            string    mgType = mgmt._type.ToString();
            if (screenRect.Contains(pos) && mgType == type)
            {
                currentSelection.Add(Unit);
            }
        }
        setUnitSelects();
        if (debugActive)
        {
            Debug.Log("Units Selected");
        }
    }
Ejemplo n.º 5
0
    public void reCacheUnits(int ID)
    {
        miners.Clear();
        mGuns.Clear();
        missiles.Clear();
        utilities.Clear();

        idle_miners.Clear();
        idle_mGuns.Clear();
        idle_missiles.Clear();
        idle_utilities.Clear();


        foreach (GameObject unit in gManager.GetComponent <unitIndex>().units[playerID])
        {
            if (unit != null)
            {
                unitAgent ai = unit.GetComponent <unitAgent> ();

                if (ai._type == unitAgent.Type.mGun)
                {
                    mGuns.Add(unit);
                    if (ai.onMission == false)
                    {
                        idle_mGuns.Add(unit);
                    }
                }
                if (ai._type == unitAgent.Type.missile)
                {
                    missiles.Add(unit);
                    if (ai.onMission == false)
                    {
                        idle_missiles.Add(unit);
                    }
                }
                if (ai._type == unitAgent.Type.miner)
                {
                    miners.Add(unit);
                    if (ai.onMission == false)
                    {
                        idle_miners.Add(unit);
                    }
                }
                if (ai._type == unitAgent.Type.utility)
                {
                    utilities.Add(unit);
                    if (ai.onMission == false)
                    {
                        idle_utilities.Add(unit);
                    }
                }
            }
        }
    }
Ejemplo n.º 6
0
 // Use this for initialization
 void Start()
 {
     podsCount = cargoPods.Length;
     uLogic    = GetComponentInParent <unitAgent> ();
     foreach (GameObject pod in cargoPods)
     {
         pod.SetActive(false);
         capacity = uLogic.rCapacity;
     }
     refresh = refreshRate;
 }
Ejemplo n.º 7
0
    void unitSelection(GameObject selected, int ID)
    {
        currentSelection.Clear();
        unitAgent logic = selected.GetComponent <unitAgent> ();

        if (logic.playerID == playerID)
        {
            currentSelection.Add(selected);
        }
        eventManager.SelectEvent(this.gameObject, playerID);
        if (debugActive)
        {
            Debug.Log("Units Selected");
        }
    }
Ejemplo n.º 8
0
    void miningEvent(int hitpoints, GameObject sender, GameObject reciever)
    {
        cutOff = false;

        if (reciever == this.gameObject)
        {
            unitAgent tempUnit = sender.GetComponent <unitAgent> ();
            if (tempUnit._type == unitAgent.Type.miner)
            {
                float rand = Random.Range(0, 10);
                if (rand < debrisRate)
                {
                    GameObject  temp      = Instantiate(debris, transform.position, Random.rotation);
                    debrisLogic tempLogic = temp.GetComponent <debrisLogic> ();
                    tempLogic.Target      = sender;
                    temp.transform.parent = transform;
                    Vector3 randScale = new Vector3(rand / debrisScale, rand / debrisScale, rand / debrisScale);
                    temp.transform.localScale = temp.transform.localScale + randScale;
                }
                resourceValue = (resourceValue - hitpoints);
                if (resourceValue > 50)
                {
                    transform.localScale -= new Vector3(0.02f, 0.02f, 0.02f);
                    Debug.Log("Damage Recieved");
                }
                if (resourceValue < 50 && resourceValue > 2)
                {
                    //float mini = (float)hitpoints / resourceReset;
                    int i = 1;
                    transform.localScale -= new Vector3(0.03f, 0.03f, 0.03f);
                    if (i == 1)
                    {
                        var myBounds = new GraphUpdateObject(GetComponent <Collider> ().bounds);
                        AstarPath.active.UpdateGraphs(myBounds);
                        i++;
                    }
                }
                if (resourceValue <= 0)
                {
                    onDamage();
                    onDeplete();
                }
            }
        }
    }
Ejemplo n.º 9
0
    // Use this for initialization
    void Start()
    {
        gManager = GameObject.Find("gameManager");

        GameObject temp = GameObject.FindGameObjectWithTag("playerSeed");

        playerID = temp.GetComponent <playerCommand>().playerID;

        List <GameObject> tempList = new List <GameObject>();

        tempList.AddRange(GameObject.FindGameObjectsWithTag("Friendly"));

        foreach (GameObject unit in tempList)
        {
            unitAgent ai = unit.GetComponent <unitAgent> ();
            if (ai.playerID == playerID)
            {
                unitsInPlay.Add(unit);
            }
        }
    }
Ejemplo n.º 10
0
 // Use this for initialization
 void Start()
 {
     manager = GetComponentInParent <unitAgent> ();
     text    = GetComponent <TextMesh> ();
 }
Ejemplo n.º 11
0
 // Use this for initialization
 void Start()
 {
     uLogic    = GetComponentInParent <unitAgent> ();
     particles = GetComponent <ParticleSystem> ();
     ticker    = startUp;
 }
Ejemplo n.º 12
0
 /** Starts searching for paths.
  * If you override this function you should in most cases call base.Start () at the start of it.
  * \see OnEnable
  * \see RepeatTrySearchPath
  */
 protected virtual void Start()
 {
     startHasRun = true;
     uLogic      = GetComponent <unitAgent> ();
     OnEnable();
 }