public static void Clear()
    {
        var gameObjects = GuidList.GetAllObjects();

        foreach (GameObject unit in gameObjects)
        {
            // Clear code
        }
    }
    void Update()
    {
        if (null == unitCounts)
        {
            unitCounts = new Dictionary <string, int>();
        }
        if ((null != lastName && null != MyName && !MyName.label.Equals(lastName)) || (-1 != TeamNumber && !thisbooleanshouldntexist))
        {
            if (null != lastName && null != MyName)
            {
                lastName = MyName.label;
            }
            if (null == unitCounts)
            {
                unitCounts = new Dictionary <string, int>();
            }
            if (null != MyName)
            {
                thisbooleanshouldntexist = true;
                if (!unitCounts.ContainsKey(MyName.label + TeamNumber))
                {
                    unitCounts.Add(MyName.label + TeamNumber, 1);
                }
                count = unitCounts[MyName.label + TeamNumber]++;
            }
        }
        StartIdent();
        World.SetTeamColor(gameObject);
        World.UpdateObjectiveSprite(gameObject);

        if (badPos)
        {
            timeNow = Time.time;
        }
        if (gameObject.transform.localPosition.y == 35 &&
            gameObject.transform.localPosition.x == 0 &&
            gameObject.transform.localPosition.z == 0 &&
            MyName == null)
        {
            badPos = true;
        }
        else
        {
            badPos    = false;
            startTime = Time.time;
        }
        float number = Convert.ToSingle(Math.Floor((float)GuidList.GetAllObjects().Count));;

        if (badPos && ((timeNow - startTime) > (number)))
        {
            GameObject.Destroy(gameObject);
        }
    }
    /**
     * Determines what objects are visible to this user
     *
     * @returns
     *      A list of all game objects visible to this user
     */
    public List <GameObject> GetUnitsVisibleToMe()
    {
        // A set of all objects that the user should be able to see
        HashSet <GameObject> visibleObjects = new HashSet <GameObject>();

        // Check the permission level of the user
        if (MyPermissionLevel == PermissionLevel.Admin || MyPermissionLevel == PermissionLevel.Spectator)
        {
            // If the user is an Admin or a Spectator

            // Add all objects to their visible objects list
            visibleObjects.UnionWith(GuidList.GetAllObjects());
        }
        else if (MyPermissionLevel == PermissionLevel.User)
        {
            // If the user is a User

            // Check if the user is a sub player and sub players currently
            // only see what their sub can see.
            if (SubPlayer && !GlobalSettings.GetSubmarineSensorLinkState())
            {
                // If this user only sees what the sub sees

                // Add the results of the sub's Ping
                visibleObjects.UnionWith(GuidList.GetGameObject(SubUnit).GetComponent <DetectorController>().Ping());

                // Add the sub itself.
                visibleObjects.Add(GuidList.GetGameObject(SubUnit));

                // Add all omnipresent objects
                visibleObjects.UnionWith(GuidList.GetOmnipresentObjects());

                // Remove all invisible objects
                visibleObjects.ExceptWith(GuidList.GetInvisibleObjects());
            }
            else
            {
                // If the user sees everything the team sees

                // Get a list of everything the team sees.
                visibleObjects.UnionWith(Team.GetTeam(TeamNumber).GetVisibleToTeam());
            }
        }

        return(visibleObjects.ToList <GameObject>());
    }
Ejemplo n.º 4
0
    public static void DumpGuidList()
    {
        Clear();
        List <GameObject> list = GuidList.GetAllObjects();

        foreach (GameObject go in list)
        {
            Dictionary <String, ISetGetValues> shell = new Dictionary <string, ISetGetValues>();
            ISetGetValues[] cList = go.GetComponents <Controller>();
            foreach (ISetGetValues sgc in cList)
            {
                if (sgc.GetType().Name == "MoverController")
                {
                    ((MoverController)sgc).x_pos = go.transform.position.x;
                    ((MoverController)sgc).y_pos = go.transform.position.y;
                }
                shell.Add(sgc.GetType().Name, sgc);
            }
            _cc.Add(go.tag + "-" + (_index++).ToString(), shell);
        }
    }
Ejemplo n.º 5
0
    public override void HandleEvent(GEvent e)
    {
        hitUnits = new Dictionary <string, string>();
        Vector3   position  = (Vector3)e.Arguments [0];
        Explosion explosion = new Explosion((int)position.x, (int)position.y, (bool)e.Arguments[1], (int)e.Arguments[2], (int)e.Arguments[3]);

        foreach (GameObject o in GuidList.GetAllObjects())
        {
            if (explosion.inRange(o))
            {
                hitUnits.Add(o.GetComponent <IdentityController>().GetGuid().ToString(), null);
                if (explosion.getIsDamaging())
                {
                    o.GetComponent <HealthController>().DamageUnit(explosion.getDamage(), "Admin");
                }
                else
                {
                    o.GetComponent <HealthController>().HealUnit(explosion.getDamage());
                }
            }
        }
    }
    public static void MoveMap(Vector3 vector)
    {
        /* Zoom-based movement scaling. */
        var scaled   = new Vector3(vector.x, vector.y, vector.z) * (mapCamera.orthographicSize + 100.0f) / 250.0f;
        var position = mapCamera.transform.localPosition;

        position.x = Mathf.Clamp(position.x + scaled.x, 0, World.Instance.Width);
        position.y = Mathf.Clamp(position.y + scaled.y, 0, World.Instance.Height);
        position.z = -(mapCamera.orthographicSize = Mathf.Clamp(mapCamera.orthographicSize + scaled.z, 1f, Mathf.Max(World.Instance.Height / 1.95f, World.Instance.Width / 1.95f)));

        mapCamera.transform.localPosition = position;

        /* Adjust unit zoom. */
        var units = GuidList.GetAllObjects();
        var ortho = mapCamera.orthographicSize;
        var ratio = 3.125f * Mathf.Pow(ortho, 0.404157f) + Mathf.Pow(ortho / 56, 1.45f);

        foreach (var unit in units)
        {
//            if (unit == null) {
//                continue;
//            }
//            unit.transform.localScale = new Vector3(ratio, ratio, 1);
//
//            var range = unit.transform.FindChild("Move Range Sprite");
//            if (range != null) {
//                  range.localScale = new Vector3(0.1155f * 15 / ratio, 0.1155f * 15 / ratio, 1);
//              }
//			range = unit.transform.FindChild("Attack Range Sprite");
//			if (range != null) {
//				range.localScale = new Vector3(0.1155f * 15 / ratio, 0.1155f * 15 / ratio, 1);
//			}
//			range = unit.transform.FindChild("Radar Range Sprite");
//			if (range != null) {
//				range.localScale = new Vector3(0.1155f * 15 / ratio, 0.1155f * 15 / ratio, 1);
//			}
        }
    }
Ejemplo n.º 7
0
    public string LoadScenario(string scenarioName)
    {
        //Debug.Log("loading scenario: " + scenarioName);

        var gameObjects = GuidList.GetAllObjects();

        foreach (GameObject gameObject in gameObjects)
        {
            NetworkManager.NetworkInstance.DestroyUnitOnNetwork(gameObject);
        }
        GuidList.Clear();

        string toReturn = Load(scenarioName);
        //Get the factories.
        ObjectFactory objectFactory = new ObjectFactory(scenarioName);

        objectFactory.LoadAllSurface();
        objectFactory.LoadAllSubSurface();
        objectFactory.LoadAllAir();
        objectFactory.LoadAllMarines();
        objectFactory.LoadEnvironmentVariables();

        return(toReturn);
    }
Ejemplo n.º 8
0
 /**
  * Retrieve a List of (both enemy and friendly) units in the world. At this
  * time, this list covers all units on the map, but this can be updated
  * later to allow for quicker region-searching if performance becomes a
  * concern.
  *
  * @return
  *      A List of GameObjects that represent the units in the
  *      world.
  */
 protected virtual List <GameObject> FindUnitsInWorld()
 {
     return(GuidList.GetAllObjects());
 }