Beispiel #1
0
        void KillMe(Selectable go)
        {
            Instantiate(Explosion, go.transform.position, go.transform.rotation);
            Selection.Remove(go.GetComponent <Selectable>());
            Bounds.SetUnits(Selection);
            go.transform.parent = null;
            MyTeam.GetComponent <LimitsMan>().CheckBuild(go.Data.Type);

            GameObject.Destroy(go.gameObject, 0.5f);
        }
Beispiel #2
0
 // Use this for initialization
 void Start()
 {
     MyArmy      = GetComponent <Game>().MyArmy;
     MyTeam      = MyArmy.GetComponent <Team>();
     Limits      = MyTeam.GetComponent <LimitsMan>();
     GameTerrain = GetComponent <Game>().GameTerrain;
 }
Beispiel #3
0
        void PlaceMe(GameObject go)
        {
            Random.InitState((int)(Time.frameCount));
            Selectable gs   = go.GetComponent <Selectable>();
            Team       team = GetTeamByID(gs.Data.Team);

            go.transform.parent = team.transform;

            if (gs.Data.Team == MyTeam.Data.TeamID)
            {
                team.GetComponent <LimitsMan>().CheckBuild(gs.Data.Type);
            }

            RaycastHit hit;

            Ray ray = Camera.main.ScreenPointToRay(new Vector3(Screen.width / 2.5f, Screen.height / 2, 0));

            if (GameTerrain.GetComponent <Collider>().Raycast(ray, out hit, Mathf.Infinity))
            {
                NavMeshAgent nm = go.GetComponent <NavMeshAgent>();
                if (nm != null)
                {
                    float   r   = gs.GetRadius() * 5;
                    Vector3 pos = Tools.GetSnap(go, hit.point + new Vector3(Random.value * r - r / 2, 0, Random.value * r - r / 2));
                    go.GetComponent <NavMeshAgent>().Warp(pos);
                }
                else
                {
                    gs.IsPlacing = true;
                    float   r   = gs.GetRadius() * 2;
                    Vector3 pos = Tools.GetSnap(go, hit.point + new Vector3(Random.value * r - r / 2, 0, Random.value * r - r / 2));
                    go.transform.position = pos;
                }
            }

            CreateRadarDot(go);
        }