public TestMissionController(BaseMission mission) : base(mission)
        {
            TestObject testObj1  = new TestObject(new Vector3K(2f, 5f, 0f), new Vector3K(0f, 0f, 0f), new Vector3K(0.75f, 0.75f, 0.75f), new Vector3K(0f, 0f, 0f));
            TestObject testObj2  = new TestObject(new Vector3K(2f, 4f, 0f), new Vector3K(0f, 0f, 0f), new Vector3K(0.75f, 0.75f, 0.75f), new Vector3K(0f, 0f, 0f));
            TestObject testObj3  = new TestObject(new Vector3K(2f, 3f, 0f), new Vector3K(0f, 0f, 0f), new Vector3K(0.75f, 0.75f, 0.75f), new Vector3K(0f, 0f, 0f));
            TestObject testObj4  = new TestObject(new Vector3K(2f, 2f, 0f), new Vector3K(0f, 0f, 0f), new Vector3K(0.75f, 0.75f, 0.75f), new Vector3K(0f, 0f, 0f));
            TestObject testObj5  = new TestObject(new Vector3K(2f, 1f, 0f), new Vector3K(0f, 0f, 0f), new Vector3K(0.75f, 0.75f, 0.75f), new Vector3K(0f, 0f, 0f));
            TestObject testObj6  = new TestObject(new Vector3K(2f, 0f, 0f), new Vector3K(0f, 0f, 0f), new Vector3K(0.75f, 0.75f, 0.75f), new Vector3K(0f, 0f, 0f));
            TestObject testObj7  = new TestObject(new Vector3K(2f, -1f, 0f), new Vector3K(0f, 0f, 0f), new Vector3K(0.75f, 0.75f, 0.75f), new Vector3K(0f, 0f, 0f));
            TestObject testObj8  = new TestObject(new Vector3K(2f, -2f, 0f), new Vector3K(0f, 0f, 0f), new Vector3K(0.75f, 0.75f, 0.75f), new Vector3K(0f, 0f, 0f));
            TestObject testObj9  = new TestObject(new Vector3K(2f, -3f, 0f), new Vector3K(0f, 0f, 0f), new Vector3K(0.75f, 0.75f, 0.75f), new Vector3K(0f, 0f, 0f));
            TestObject testObj10 = new TestObject(new Vector3K(2f, -4f, 0f), new Vector3K(0f, 0f, 0f), new Vector3K(0.75f, 0.75f, 0.75f), new Vector3K(0f, 0f, 0f));

            AddObject(ObjectFactory.GetObject(testObj1));
            AddObject(ObjectFactory.GetObject(testObj2));
            AddObject(ObjectFactory.GetObject(testObj3));
            AddObject(ObjectFactory.GetObject(testObj4));
            AddObject(ObjectFactory.GetObject(testObj5));
            AddObject(ObjectFactory.GetObject(testObj6));
            AddObject(ObjectFactory.GetObject(testObj7));
            AddObject(ObjectFactory.GetObject(testObj8));
            AddObject(ObjectFactory.GetObject(testObj9));
            AddObject(ObjectFactory.GetObject(testObj10));

            waveManager = new WaveManager();
            waveManager.MissionController = this;
        }
Esempio n. 2
0
        public static BaseMissionController GetMission(string roomID, string missionName)
        {
            lock (Server.RoomControllers) {
                RoomController room = Server.RoomControllers.Find(x => x.Room.ID.Equals(roomID));
                if (room == null)
                {
                    throw new Exception(string.Format("unknow room with id: {0}", roomID));
                }

                BaseMissionController missionController = room.MissionController;
                BaseMission           mission           = null;

                if (missionController != null)
                {
                    return(missionController);
                }

                switch (missionName)
                {
                case "TestMission":
                    mission = new TestMission();
                    break;

                default:
                    throw new Exception(string.Format("unknow mission name: {0}", missionName));
                }

                room.MissionController         = MissionFactory.GetMissionController(mission, room);
                room.MissionController.Mission = mission;

                Server.Updater.OnUpdate += room.MissionController.Update;
                return(room.MissionController);
            }
        }
Esempio n. 3
0
        public static void DoSync()
        {
            lock (Server.ClientsLock) {
                for (int i = 0; i < Server.ClientControllers.Count; i++)
                {
                    if (Server.ClientControllers[i].MissionController == null)
                    {
                        continue;
                    }

                    BaseMission mission = Server.ClientControllers[i].MissionController.Mission;

                    if (Server.ClientControllers[i] != null && Server.ClientControllers[i].Actualy)
                    {
                        NetDataEvent allResponse = new NetDataEvent(EventTypes.SyncMission, new Dictionary <string, ObjectWrapper>()
                        {
                            { "mission", new ObjectWrapper <BaseMission>(mission) }
                        });

                        lock (Server.ClientControllers[i].MissionController.Locker) {
                            Server.SendEvent(Server.ClientControllers[i], Utils.ToBytesJSON(allResponse), "EventGameManagerHandleSyncMission");
                        }

                        Server.ClientControllers[i].MissionFirstInited = true;
                    }
                }
            }
        }
Esempio n. 4
0
    public void ReAssignMission()
    {
        if (!populated)
        {
            PopulateList();
            //return;
        }


        //Grab the selected cannon from the activity manager.
        BaseItemCard selectedCard = ActivityManager.Instance.SelectedCard;

        //Grab the first list of missions on the list.
        if (AssignedMission == null)
        {
            AssignedMission = selectedCard.Missions[0];
        }

        //Set teh mission label
        MissionName.text = AssignedMission.DisplayName;

        int index = 0;

        //Go through the mission and assign the badge at index of the objective
        foreach (BaseMission.GameObjective gobjective in  AssignedMission.MissionObjectives)
        {
            _objectiveslist[index].AssignedObjective = gobjective;
            index++;
        }
    }
Esempio n. 5
0
 public void AddMission(BaseMission baseMission)
 {
     _missions.Add(baseMission);
     foreach (var agent in _agents.ToArray())
     {
         StartMission(agent, baseMission);
     }
 }
Esempio n. 6
0
        private void StartMission(IAgent agent, BaseMission mission)
        {
            Detach(agent);
            bool hasNext = mission.SendJob(agent);

            if (!hasNext)
            {
                _missions.Remove(mission);
            }
        }
Esempio n. 7
0
        public BaseMissionController(BaseMission mission)
        {
            Mission = mission;

            CollisionHandler = new CollisionHandler();

            PhysicsSolver        = new PhysicsSolver();
            PhysicsSolver.OnAdd += CollisionHandler.OnCollide;

            Physics = new Physics(-1100, -1100, 1100, 1100, 0, 0, false);
            Physics.SetSolver(PhysicsSolver);
        }
Esempio n. 8
0
        public Room(string name, string ownerID)
        {
            ID = Guid.NewGuid().ToString();

            Name    = name;
            OwnerID = ownerID;

            List <Type> missions = BaseMission.GetMissionTypes();

            if (missions.Count > 0)
            {
                MissionName = missions[0].Name;
            }
        }
Esempio n. 9
0
    public void Start()
    {
        var missionClass = PlayerController.Instance.CurrentMission?.MissionClass ?? typeof(TestMission);
        var instance     = Activator.CreateInstance(missionClass);

        _mission = (BaseMission)instance;
        GameEvents.current.SCORE_CHANGED += _mission.UpdateScore;
        _mission.CreateAsteroid           = CreateAsteroid;
        _mission.CreateMedic              = CreateMedic;
        _mission.Waiting       = Waiting;
        _mission.Random        = Random.Range;
        _mission.OnMissionEnd += OnMissionEnd;
        _mission.StartMission();
    }
    public void ApplyPhaseStatsToCards()
    {
        //Check the stats cannon completion and find the item card and feed its breathless mission the stats at the index.

        int cardindex = -1;
        int i         = 0;

        //Find matching item card at cannon type and grab the index.
        foreach (BasePhase.PhaseData pd in _infinteModeData.PhaseList)
        {
            cardindex = FindCannonCard(pd.PhaseStatistics.CompletionCannon);

            //If we didnt return a proper value just leave as there is nothing.
            if (cardindex == -1)
            {
                return;
            }

            //We have found a match if we made it here. Lets set the card dirty to be updated.
            CardDeck[cardindex].IsDirty = true;

            //Since the phase data is for the given item card. lets add the statistics.
            CardDeck[cardindex].ItemStats.AddStatistics(pd.PhaseStatistics);

            //Grab the mission of the card type.
            BaseMission m = CardDeck[cardindex].BreathlessMission;

            //here we check if we have a breathless mission, or we return.
            if (!m)
            {
                return;
            }


            //Lets check if our mission objectives are out of the range we willt ry to access it at.
            if (m.MissionObjectives[i] == null)
            {
                print("Trying to assign a phase stat for a mission that is not there!");
                return;
            }

            //Set the objective at the same index as phase statistics.
            // TODO: try not to overwrite if the stats are lesser.
            m.MissionObjectives[i].ObjectiveStatistics = pd.PhaseStatistics;

            //Incrementor so we can access the index of the mission objectives as well.
            i++;
        }
    }
Esempio n. 11
0
    private void OnEnable()
    {
        roomNameInput.text = string.Empty;

        List <TMP_Dropdown.OptionData> options = new List <TMP_Dropdown.OptionData>();
        List <Type> types = BaseMission.GetMissionTypes();

        missionDropDown.ClearOptions();

        foreach (Type t in types)
        {
            options.Add(new TMP_Dropdown.OptionData(t.Name.ToString()));
        }

        missionDropDown.AddOptions(options);
    }
Esempio n. 12
0
        public static BaseMissionController GetMissionController(BaseMission mission, RoomController roomController)
        {
            BaseMissionController result = null;

            if (mission.GetType() == typeof(TestMission))
            {
                result = new TestMissionController(mission);
            }
            else
            {
                throw new Exception("unknow mission type " + mission.GetType().ToString());
            }

            if (result != null)
            {
                result.RoomController = roomController;
            }
            return(result);
        }
Esempio n. 13
0
    //Applies stat to given mission.
    //Assgns stats to every objective in the mission.
    public void ApplyStatsToMission(Statistics stats, string missionName)
    {
        //Lets get the mission first.
        BaseMission m = GetMissionByName(missionName);

        //Then go through all the missions objectives and assign the passed in stats.
        foreach (BaseMission.GameObjective g in m.MissionObjectives)
        {
            if (g == null)
            {
                print("Trying to assign a phase stat for a mission that is not there!");
                return;
            }

            g.ObjectiveStatistics = stats;
        }

        //Mark this card dirty for the le ule buggars
        IsDirty = true;
    }
Esempio n. 14
0
    void PopulateList()
    {
        //Grab the selected cannon from the activity manager.
        BaseItemCard selectedCard = ActivityManager.Instance.SelectedCard;

        if (selectedCard == null)
        {
            return;
        }

        if (_objectiveslist == null)
        {
            Debug.LogError("NO OBJECTIVE LIST!! WTF!!");
            _objectiveslist = new List <FUIObjectiveBadge>();
        }


        //Grab the first list of missions on the list.
        BaseMission mission = selectedCard.Missions[0];

        //Store a placeholder objective badge
        FUIObjectiveBadge newBadge = null;

        foreach (BaseMission.GameObjective gobjective in mission.MissionObjectives)
        {
            //Allocate the new badge.
            newBadge = NGUITools.AddChild(ObjectivesListTable.gameObject, ObjectiveBadgePrefab.gameObject).GetComponent <FUIObjectiveBadge>();

            //Set the variables
            newBadge.AssignedObjective = gobjective;

            //Add it to the list.
            _objectiveslist.Add(newBadge);

            //Repositioning the table.
            ObjectivesListTable.Reposition();
        }


        populated = true;
    }
    public void PunchPhaseTime(float t, EntityFactory.CannonTypes cannonCompletion)
    {
        int index     = 0;
        int cardIndex = -1;

        //if we have somthign in the list we set the timer to the last phase in the list.
        if (_infinteModeData.PhaseList.Count > 0)
        {
            //Grabbing index for the current phase, which is the one that should be getting punched.
            index = _infinteModeData.PhaseList.Count - 1;

            //Setting time for the completion punch.
            _infinteModeData.PhaseList[index].PhaseCompletionPunch = t;

            //Set the cannon type in the statistics.
            _infinteModeData.PhaseList[index].PhaseStatistics.CompletionCannon = cannonCompletion;

            //We should stop the time for the stats here too.
            _infinteModeData.PhaseList[index].PhaseStatistics.StopTimer();

            //Lets add the phases stats to the main game stats.
            //GameObjectTracker.GetGOT().gameRunStatistics.AddStatistics(_infinteModeData.PhaseList[index].PhaseStatistics);

            //Perform a test on the completion cannon if there is a matching item card.
            cardIndex = FindCannonCard(cannonCompletion);

            //If we didnt return a proper value just leave as there is nothing.
            if (cardIndex == -1)
            {
                return;
            }


            //We have found a match if we made it here. Lets set the card dirty to be updated.
            CardDeck[cardIndex].IsDirty = true;

            //Since the phase data is for the given item card. lets add the statistics.
            CardDeck[cardIndex].ItemStats.AddStatistics(_infinteModeData.PhaseList[index].PhaseStatistics);

            //Grab the mission
            BaseMission m = CardDeck[cardIndex].BreathlessMission;

            //here we check if we have a breathless mission, or we return.
            if (!m)
            {
                return;
            }


            //Lets check if our mission objectives are out of the range we willt ry to access it at.
            if (m.MissionObjectives[index] == null)
            {
                print("Trying to assign a phase stat for a mission that is not there!");
                return;
            }

            //Set the objective at the same index as phase statistics.
            m.MissionObjectives[index].ObjectiveStatistics = _infinteModeData.PhaseList[index].PhaseStatistics;

            //SaveItemCardData();
        }
    }
Esempio n. 16
0
        public void SubmitMission(string server, BaseMission baseMission)
        {
            var sharedState = _serversHub.Get(server);

            sharedState.Missions.AddMission(baseMission);
        }
Esempio n. 17
0
    private void HandleSyncMission(byte[] data)
    {
        NetDataEvent ndata = Utils.FromBytesJSON <NetDataEvent>(data);

        BaseMission mission = (BaseMission)ndata.Values["mission"].ObjectValue;

        if (mission.Objects == null)
        {
            mission.Objects = new Dictionary <string, BaseMissionObject>();
        }
        if (mission.DynamicObjects == null)
        {
            mission.DynamicObjects = new Dictionary <string, BaseMissionObject>();
        }

        Dictionary <string, BaseMissionObject> objects = mission.Objects;

        MergeDictionary(objects, mission.DynamicObjects);

        //instantiate objects on client created on server
        foreach (var o in objects.ToList())
        {
            if (o.Value.Destroyed)
            {
                continue;
            }

            bool isOwn = o.Value.OwnerID.Equals(NetManager.I.ID);

            if (!NetworkObjectDispenser.I.Objects.ContainsKey(o.Value.ID))
            {
                GameObject go = SpawnObject(o.Value.ID, o.Value.NameID, o.Value.Position.FromServerVector3(), o.Value.Center.FromServerVector3(), o.Value.Size.FromServerVector3(), o.Value.EulerAngles.FromServerVector3(), isOwn);

                if (o.Value is PlayerObject)
                {
                    players.Add(go.GetComponent <Player>());

                    if (isOwn)
                    {
                        CameraController.I.Target = go;
                    }
                }
            }
        }

        //sync exist objects
        foreach (var o in objects.ToList())
        {
            if (NetworkObjectDispenser.I.Objects.ContainsKey(o.Value.ID))
            {
                NetworkMissionObject obj = NetworkObjectDispenser.I.Objects[o.Value.ID];
                obj.SyncTransform(o.Value.Position.FromServerVector3(), o.Value.EulerAngles.FromServerVector3());

                if (o.Value is IHuman)
                {
                    (obj as IHumanObject).SyncHealth((o.Value as IHuman).Health, (o.Value as IHuman).MaxHealth);

                    if (o.Value is PlayerObject && o.Value.OwnerID.Equals(NetManager.I.ID))
                    {
                        GameGUIManager.I.UpdateHealthBar((o.Value as IHuman).Health, (o.Value as IHuman).MaxHealth);
                    }
                }

                if (o.Value.Destroyed)
                {
                    NetworkObjectDispenser.I.DestroyObject(o.Value.ID);
                }
            }
        }
    }