public MissionStat(int numOfMission, MissionBase mission, MissionBase[] missions)
            {
                this.mission           = mission;
                NumOfMission           = numOfMission;
                NumOfWrongAnswers      = 0;
                NumOfRightAnswers      = 0;
                TimeSpanMissionSeconds = 0;
                SuccessPercent         = 0;

                foreach (var m in missions)
                {
                    if (m.NumOfMission != numOfMission)
                    {
                        continue;
                    }
                    TimeSpanMissionSeconds += m.TimeSpanOnMissionSeconds;
                    if (m.IsSolvedRight())
                    {
                        NumOfRightAnswers++;
                    }
                    else
                    {
                        NumOfWrongAnswers++;
                    }
                }
                try
                {
                    SuccessPercent = Convert.ToDouble(NumOfRightAnswers) / NumOfWrongAnswers;
                }
                catch { }
            }
Beispiel #2
0
    private void Awake()
    {
        if (!_IsLobby)
        {
            _Mission = GetComponent <MissionBase>();
        }

        Transform[] temp       = _RespawnParent.GetComponentsInChildren <Transform>();
        var         tempLength = temp.Length - 1;

        _RespawnPositions = new Transform[tempLength];

        int i = 0;

        foreach (Transform respawn in temp)
        {
            if (respawn != _RespawnParent)
            {
                _RespawnPositions[i] = respawn;
                i++;
            }
        }

        if (!_IsLobby)
        {
            _ExitPosition.gameObject.SetActive(false);
        }
    }
Beispiel #3
0
    public void FillWithMission(MissionBase m, MissionUI owner)
    {
        descText.text   = m.GetMissionDesc();
        rewardText.text = m.reward.ToString();

        if (m.isComplete)
        {
            claimButton.gameObject.SetActive(true);
            progressText.gameObject.SetActive(false);

            background.color = completedColor;

            progressText.color = Color.white;
            descText.color     = Color.white;
            rewardText.color   = Color.white;

            claimButton.onClick.AddListener(delegate { owner.Claim(m); });
        }
        else
        {
            claimButton.gameObject.SetActive(false);
            progressText.gameObject.SetActive(true);

            background.color = notCompletedColor;

            progressText.color = Color.black;
            descText.color     = completedColor;

            progressText.text = ((int)m.progress) + " / " + ((int)m.max);
        }
    }
Beispiel #4
0
    public override void InitializeMission(GameObject player, MissionBase Template)
    {
        base.InitializeMission(player, Template);

        if (GameManager.Instance.PlayingState == PlayingState.ControllerCalibration || GameManager.Instance.PlayingState == PlayingState.PraticeMode) // only do this in play mode, not practice
        {
            return;
        }

        int tries = 0;

        deadlineTime = Random.Range(GameManager.Instance.TimeLeft - maxIntervalForDeadline,
                                    GameManager.Instance.TimeLeft - minIntervalForDeadline);

        if (deadlineTime <= 0 && tries < 10)
        {
            deadlineTime = Random.Range(GameManager.Instance.TimeLeft - minIntervalForDeadline,
                                        GameManager.Instance.TimeLeft - maxIntervalForDeadline);
            tries++;
        }

        if (deadlineTime <= 0) // get new mission
        {
            //Debug.Log(this.Player + " Not enough time for defend mission. Getting new mission instead...");
            MissionManager.Instance.GetNewMissionToSinglePlayer(this.Player);
        }
        else // add mission timer mark
        {
            GameManager.Instance.TimeBar.TimeMarks.Add(deadlineTime);
            StuffToShowInGUI    = "Deadline: " + deadlineTime.ToString();
            targetHasNotDiedYet = true;
        }
    }
 public void RemoveFavorite(MissionBase mission) {
     var favorite = Favorites.FirstOrDefault(f => f.Matches(mission));
     if (favorite == null)
         return;
     Favorites.Remove(favorite);
     SaveSettings();
 }
Beispiel #6
0
    public override void InitializeMission(GameObject player, MissionBase Template)
    {
        base.InitializeMission(player, Template);

        /*if (target != null)
         *  targetWasAliveWhenMissionBegan = true;*/
    }
        public void MissionStepDescriptionList(string type
                                               , MissionStepDescriptionListHeadFootTemplate head
                                               , MissionStepDescriptionListHeadFootTemplate foot
                                               , MissionStepDescriptionListItemTemplate item)
        {
            MissionBase missionBase = MissionBO.Instance.GetMissionBase(type);

            if (missionBase != null)
            {
                if (missionBase.StepDescriptions != null)
                {
                    int i = 0;
                    head();
                    foreach (string stepDescription in missionBase.StepDescriptions)
                    {
                        item(i++, stepDescription);
                    }
                    foot();
                }
            }
            else
            {
                //TODO:
            }
        }
Beispiel #8
0
    public override void InitializeMission(GameObject player, MissionBase Template)
    {
        base.InitializeMission(player, Template);

        /*if (target != null)
            targetWasAliveWhenMissionBegan = true;*/
    }
Beispiel #9
0
 public PreGameLaunchCancelleableEvent(Game game, Collection collection, MissionBase mission, Server server)
 {
     Game       = game;
     Collection = collection;
     Mission    = mission;
     Server     = server;
 }
Beispiel #10
0
    public void Claim(MissionBase m)
    {
        PlayerData.instance.ClaimMission(m);

        // Rebuild the UI with the new missions
        Open();
    }
Beispiel #11
0
    public override void InitializeMission(GameObject player, MissionBase Template)
    {
        base.InitializeMission(player, Template);

        if (GameManager.Instance.PlayingState == PlayingState.ControllerCalibration || GameManager.Instance.PlayingState == PlayingState.PraticeMode) // only do this in play mode, not practice
            return;

        int tries = 0;

        deadlineTime = Random.Range(GameManager.Instance.TimeLeft - maxIntervalForDeadline,
                                    GameManager.Instance.TimeLeft - minIntervalForDeadline);

        if (deadlineTime <= 0 && tries < 10)
        {
            deadlineTime = Random.Range(GameManager.Instance.TimeLeft - minIntervalForDeadline,
                                    GameManager.Instance.TimeLeft - maxIntervalForDeadline);
            tries++;

        }

        if (deadlineTime <= 0) // get new mission
        {
            //Debug.Log(this.Player + " Not enough time for defend mission. Getting new mission instead...");
            MissionManager.Instance.GetNewMissionToSinglePlayer(this.Player);
        }
        else // add mission timer mark
        {
            GameManager.Instance.TimeBar.TimeMarks.Add(deadlineTime);
            StuffToShowInGUI = "Deadline: " + deadlineTime.ToString();
            targetHasNotDiedYet = true;
        }
    }
Beispiel #12
0
        public async Task ReturnMission(MissionBase mission)
        {
            var movement = await SendHttpRequest(Builder.BuildMovementRequest());

            var missionReturnId = await DataProvider.FleetMovementProvider.GetMissionReturnId(movement.ResponseHtmlDocument, mission);

            await SendHttpRequest(Builder.BuildReturnMissionRequest(missionReturnId));
        }
 public void AddFavorite(MissionBase mission) {
     lock (Favorites) {
         if (Favorites.Any(f => f.Matches(mission)))
             return;
         Favorites.Add(new FavoriteMission(mission));
     }
     SaveSettings();
 }
Beispiel #14
0
        public void AddRecent(MissionBase mission)
        {
            var recentModSet = new RecentMission(mission);

            RecentMissions.AddLocked(recentModSet);
            mission.RefreshLastJoinedOn();
            SaveSettings();
        }
 void HandleMissionSwitch(MissionBase value)
 {
     if (_ignoreUpdate)
     {
         return;
     }
     UpdateRecentMission(value);
     UpdateMod();
 }
        public override bool MarkMissionDone(string missionVariableName)
        {
            MissionBase mission = new MissionBase()
            {
                VariableName = missionVariableName
            };

            return(MissionManager.IsMissionDone(mission));
        }
    public void Claim(MissionBase m)
    {
        PlayerData.instance.ClaimMission(m);

        // Rebuild the UI with the new missions
        Open();
        achievementPopup.gameObject.SetActive(true);
        rewardCount.text = m.reward.ToString();
    }
Beispiel #18
0
    /// <summary>
    /// 添加任务
    /// </summary>
    public void AddMission()
    {
        int val = Random.Range(0, (int)MissionBase.MissionType.MAX);

        MissionBase newMission = MissionBase.GetNewMissionFromType((MissionBase.MissionType)val);

        newMission.Created();

        missions.Add(newMission);
    }
Beispiel #19
0
 void ShuffleMissions(List <MissionBase> missions)
 {
     for (int i = 0; i < missions.Count; i++)
     {
         MissionBase temp   = missions[i];
         int         random = Random.Range(0, missions.Count);
         missions[i]      = missions[random];
         missions[random] = temp;
     }
 }
Beispiel #20
0
 MissionBase CreateLocalMission(MissionBase mission)
 {
     if (mission is MissionFolder)
     {
         return(mission);
     }
     return(Game.Lists.Missions.FirstOrDefault(
                y => y.Name.Equals(mission.Name, StringComparison.OrdinalIgnoreCase))
            ?? mission);
 }
    // important that this is called in Awake (before Start)!
    private void Awake()
    {
        missionBase = GetComponent<MissionBase>();
        if (missionBase == null)
            Debug.Log("ERROR - needs to have a mission attached to template game object!");

        this.chooseTarget = missionBase.HowToChooseTarget;

        DecideHowToChooseTarget();
    }
 void HandleMissionStateChanged(MissionBase sender)
 {
     if (sender.State == ContentState.UpdateAvailable)
     {
         _updates.Items.AddWhenMissing(sender);
     }
     else
     {
         _updates.Items.RemoveLocked(sender);
     }
 }
Beispiel #23
0
 public void AddFavorite(MissionBase mission)
 {
     lock (Favorites) {
         if (Favorites.Any(f => f.Matches(mission)))
         {
             return;
         }
         Favorites.Add(new FavoriteMission(mission));
     }
     SaveSettings();
 }
Beispiel #24
0
    private void Awake() // important that this is called in Awake (before Start)!
    {
        missionBase = GetComponent <MissionBase>();
        if (missionBase == null)
        {
            Debug.Log("ERROR - needs to have a mission attached to template game object!");
        }

        this.chooseTarget = missionBase.HowToChooseTarget;

        DecideHowToChooseTarget();
    }
Beispiel #25
0
 public void RemoveFavorite(MissionBase mission)
 {
     lock (Favorites) {
         var favorite = Favorites.FirstOrDefault(f => f.Matches(mission));
         if (favorite == null)
         {
             return;
         }
         Favorites.Remove(favorite);
     }
     SaveSettings();
 }
        public void MissionBase(string type, MissionBaseTemplate template)
        {
            MissionBase missionBase = MissionBO.Instance.GetMissionBase(type);

            if (missionBase != null)
            {
                template(missionBase);
            }
            else if (MissionBO.Instance.GetAllMissionBases().Count > 0)
            {
                template(MissionBO.Instance.GetAllMissionBases()[0]);
            }
        }
Beispiel #27
0
        void HandleOverlay(MissionBase mission)
        {
            if (_missionsViewModel.MissionInfoOverlayViewModel.IsActive &&
                !(AllowInfoOverlay(mission)))
            {
                _missionsViewModel.MissionInfoOverlayViewModel.TryClose();
            }

            if (_missionsViewModel.MissionInfoOverlayViewModel.IsActive &&
                !mission.Controller.HasMultipleVersions())
            {
                _missionsViewModel.MissionInfoOverlayViewModel.TryClose();
            }
        }
Beispiel #28
0
 void SetTargetBaseAndIntel(MissionBase template)
 {
     if (template is MissionIntel)
     {
         MissionIntel intel = (MissionIntel)template;
         this.IntelPropToSteal = intel.IntelPropToSteal;
         PickUpObject          = IntelPropToSteal.GetComponent <PickUpObject>();
         //Debug.Log("Successfully casted from MissionBase to MissionIntel");
     }
     else
     {
         Debug.Log("ERROR - could not cast from MissionBase to MissionIntel!");
     }
 }
        public async Task ShowUploadOverlay(MissionBase content)
        {
            var missions =
                await MissionList.GetMyMissions(DomainEvilGlobal.SelectedGame.ActiveGame);

            var vm = _uploadViewModelFactory();

            vm.ExistingMissions = missions.Select(x => x.Name).ToList();
            vm.UploadNewMission = !missions.Any();
            vm.Content          = content;

            MissionUploadViewModel = vm;
            ShowOverlay(MissionUploadViewModel);
        }
Beispiel #30
0
    public void RemoveAllMissions()
    {
        for (int i = 0; i < Players.Count; i++)
        {
            //Players[i].GetComponent<Player>().RemoveAllMissionsOnMe(); // does not work
            MissionBase m = Players[i].GetComponent <MissionBase>();
            //DestroyImmediate(m);

            if (m != null)
            {
                InstantiatedMissions.Remove(m);
                m.DestroyMission();
            }
        }
    }
Beispiel #31
0
            static string GetMissionParameter(MissionBase mission)
            {
                var missionFile = mission.Controller.GetMissionFile();

                if (missionFile == null)
                {
                    return(null);
                }

                var folder = missionFile as IAbsoluteDirectoryPath;

                return(folder != null
                    ? GetMissionFolderParameter(folder)
                    : GetMissionParameterBasedOnType(mission, (IAbsoluteFilePath)missionFile));
            }
Beispiel #32
0
    MissionBase GetUniqueMission() // "relative random" mission
    {
        Random.seed = (int)System.DateTime.Now.Ticks;

        MissionBase m     = FourPotentialMissionsAvailable[Random.Range(0, FourPotentialMissionsAvailable.Count)];
        int         tries = 0;

        while (AlreadyChosenMissions.Contains(m) && tries < ChanceOfGettingUniqueMissions)
        {
            m = FourPotentialMissionsAvailable[Random.Range(0, FourPotentialMissionsAvailable.Count)];
            tries++;
        }

        AlreadyChosenMissions.Add(m);
        return(m);
    }
Beispiel #33
0
    public void SetMission()                                              //definir as missions na tela
    {
        for (int i = 0; i < 2; i++)                                       //como sao 2
        {
            MissionBase mission = GameManager.gm.GetMission(i);           //chama a funçao
            missionDescription[i].text = mission.GetMissionDescription(); //vai esse texto na cena
            missionReward[i].text      = "Recompensa: " + mission.reward;
            missionProgress[i].text    = mission.progress + mission.currentProgress + " / " + mission.max;
            if (mission.GetMissionComplete())    //se ja foi completada
            {
                rewardButton[i].SetActive(true); // aparece o botao
            }
        }

        GameManager.gm.Save(); // depois que gera uma nova mission salva
    }
Beispiel #34
0
    public void SetMission()
    {
        for (int i = 0; i < 2; i++)
        {
            MissionBase mission = GameManager.gm.GetMission(i);
            missionDescription[i].text = mission.GetMissionDescription();
            missionReward[i].text      = "Reward: " + mission.reward;
            missionProgress[i].text    = mission.currentProgress + "/" + mission.max;
            if (mission.GetMissionComplete())
            {
                rewardButton[i].SetActive(true);
            }
        }

        GameManager.gm.Save();
    }
        public async Task <int> GetReturnIdForMission(HtmlDocument document, MissionBase mission)
        {
            return(await Task.Run(() =>
            {
                var missionReturnNode = document.GetElementbyId("inhalt")
                                        .Descendants("div")
                                        .First(n => n.Attributes.Any(a => a.OriginalName == "data-arrival-time" &&
                                                                     a.Value == mission.ArrivalTimestamp.ToString()));

                var missionReturnId = missionReturnNode.Descendants("span")
                                      .First(s => s.Attributes.Any(a => a.Value.Contains("reversal")))
                                      .GetAttributeValue("ref", null);

                return Convert.ToInt32(missionReturnId);
            }));
        }
Beispiel #36
0
    public override void InitializeMission(GameObject player, MissionBase Template)
    {
        base.InitializeMission(player, Template);
        counter = 0;
        this.TargetPool = Template.TargetPool; // needs to know about all potential targets (bases) to see if somebody else won before me
        SetTargetBaseAndIntel(Template);

        ring = (GameObject)Instantiate(MissionManager.Instance.RingPrefabForIntelMission, this.Player.transform.position, Quaternion.identity);
        ring.renderer.enabled = false;
        ring.name = "_ring_ "+ this.Player;
        ring.transform.localEulerAngles = new Vector3(90, 180, 0);

        pickupObjectScript = IntelPropToSteal.GetComponent<PickUpObject>();
        if (pickupObjectScript == null)
            Debug.Log("ERROR - USB key doesn't have pickup object script");

        missionIsDone = false;
    }
        void UpdateRecentMission(MissionBase value) {
            var recentMission = value != null && value.ObjectTag != null ? new RecentMission(value) : null;

            var ms = Collection;
            if (ms != null) {
                ms.RecentMission = recentMission;
                DomainEvilGlobal.Settings.RaiseChanged();
            } else {
                var gs = _game;
                gs.Settings.Recent.Mission = recentMission;
            }
        }
 void HandleMissionSwitch(MissionBase value) {
     if (_ignoreUpdate)
         return;
     UpdateRecentMission(value);
     UpdateMod();
 }
        public void SwitchToServer() {
            var modSet = Collection;
            _ignoreUpdate = true;
            try {
                if (modSet == null)
                    _parkedMission = Mission;
                else
                    modSet.ParkedMission = Mission;
                Mission = null;

                Server = modSet == null ? _parkedServer : modSet.ParkedServer;
            } finally {
                _ignoreUpdate = false;
            }
            UpdateMod();
        }
 public RequestPublishMission(MissionBase mission) {
     Mission = mission;
 }
 public void SetNotes(MissionBase mission, string text) {
     SetNotes(mission, "Server", text);
 }
Beispiel #42
0
    public GameObject ChooseRandomTarget(MissionBase template)
    {
        System.Random random = new System.Random();

        switch (this.HowToChooseTarget)
        {
            //case HowToChooseTarget.ChooseTargetBasedOnChildren:
            case HowToChooseTarget.ChooseTargetBasedOnList:
            case HowToChooseTarget.ChooseTargetAmongAllPlayers:
                int randomAmongAll = GetUniqueTarget(TargetNumbersUsed, ChanceOfGettingUniqueTarget, 0, template.TargetPool.Count);
                //print(r);
                return template.TargetPool[randomAmongAll];
                break;

            case HowToChooseTarget.ChooseTargetAmongAllPlayersExceptMe:
                int counter = 0;
                int randomExceptMyself = GetUniqueTarget(TargetNumbersUsed, ChanceOfGettingUniqueTarget, 0, template.TargetPool.Count);

                GameObject tempTarget = template.TargetPool[randomExceptMyself];
                if (this.HowToChooseTarget == HowToChooseTarget.ChooseTargetAmongAllPlayersExceptMe) // try to avoid choosing myself
                {
                    while (tempTarget == this.Player && counter < 100) // try to pick a new target
                    {
                        randomExceptMyself = GetUniqueTarget(TargetNumbersUsed, ChanceOfGettingUniqueTarget, 0, template.TargetPool.Count);
                        tempTarget = template.TargetPool[randomExceptMyself];
                        counter++;
                    }

                    /*if (tempTarget == this.Player)
                        print("got myself");*/

                }
                return template.TargetPool[randomExceptMyself];
                break;

            default:
                //print("default");
                return null;
                break;

        }
    }
 public bool IsFavorite(MissionBase mission) => Favorites.Any(f => f.Matches(mission));
 public bool HasNotes(MissionBase mission) => HasNotes(mission, "Mission");
 public PreGameLaunchCancelleableEvent(Game game, Collection collection, MissionBase mission, Server server) {
     Game = game;
     Collection = collection;
     Mission = mission;
     Server = server;
 }
Beispiel #46
0
 public string GetNotes(MissionBase mission) {
     return GetNotes(mission, "Mission");
 }
 public MissionController(MissionBase mission) : base(mission) {
     Mission = mission;
     if (Mission.IsLocal)
         Model.State = ContentState.Local;
 }
 static bool AllowInfoOverlay(MissionBase mission) {
     return mission is Mission && !mission.IsLocal;
 }
 public Task PublishMission(MissionBase mission) {
     return _missionsViewModel.ShowUploadOverlay(mission);
 }
Beispiel #50
0
    // An abstract function has to be overridden while a virtual function may be overridden.
    public virtual void InitializeMission(GameObject player, MissionBase Template)
    {
        if (Template == null)
            Debug.Log("ERROR, Mission Templates have not been assigned for " + player);

        if (Template.TargetPool.Count <= 0)
            Debug.Log("ERROR - Target pool is empty for " + player);

        // Use specific values
        this.Player = player;
        this.PlayerScript = player.GetComponent<Player>();

        if (PlayerScript == null)
            Debug.Log("ERROR - mission doesn't have link to player! " + this);

        this._missionIsActive = true;

        this.HowToChooseTarget = Template.HowToChooseTarget;

        this.Target = ChooseRandomTarget(Template);

        // Rumble IDs
        if (Target.GetComponent<TargetIDColor>() == null)
            Debug.Log("ERROR  - target for " + gameObject + " doesn't have a TargetIDColor!");
        this.TargetIDColorState = Target.GetComponent<TargetIDColor>().TargetIDColorState;

        // Use template values
        this.MissionType = Template.MissionType;
        this.Points = Template.Points;
        this.MissionIDRumble = Template.MissionIDRumble;
        this.isInstanceMission = true;

        StopAllRumble();

        if (GameManager.Instance.PlayingState != PlayingState.ControllerCalibration && GameManager.Instance.PlayingState != PlayingState.TalkingBeforeControllerCalibration)
        {
            GameObject Particles = (GameObject)Instantiate(GameManager.Instance.MissionInitializedParticles);
            Particles.GetComponent<MissionParticle>().PlayerToFollow = this;
            GameObject ParticlesClone = (GameObject)Instantiate(GameManager.Instance.MissionInitializedParticles);
            Particles.GetComponent<MissionParticle>().SetUpParticleClone(ParticlesClone, this.Player);
        }
        HasHeardMissionRumble = false;

        //Debug.Log(string.Format("Mission {0} initialized for Player {1} with Target {2}", this, this.Player, this.Target.transform.name));

        ThisButtonPressNumberUp = 0;
        ThisButtonPressNumberDown = 0;
        TimeSinceReceivedMission = 0;

        HasHeardMissionAtLeastOneTime = false;

        StartCoroutine(WaitForMissionToGetActive());
    }
 public void AddRecent(MissionBase mission) {
     var recentModSet = new RecentMission(mission);
     RecentMissions.AddLocked(recentModSet);
     mission.RefreshLastJoinedOn();
     SaveSettings();
 }
        void HandleOverlay(MissionBase mission) {
            if (_missionsViewModel.MissionInfoOverlayViewModel.IsActive &&
                !(AllowInfoOverlay(mission)))
                _missionsViewModel.MissionInfoOverlayViewModel.TryClose();

            if (_missionsViewModel.MissionInfoOverlayViewModel.IsActive &&
                !mission.Controller.HasMultipleVersions())
                _missionsViewModel.MissionInfoOverlayViewModel.TryClose();
        }
Beispiel #53
0
    void SetTargetBaseAndIntel(MissionBase template)
    {
        if (template is MissionIntel)
        {
            MissionIntel intel = (MissionIntel)template;
            this.IntelPropToSteal = intel.IntelPropToSteal;
            PickUpObject = IntelPropToSteal.GetComponent<PickUpObject>();
            //Debug.Log("Successfully casted from MissionBase to MissionIntel");

        }
        else
            Debug.Log("ERROR - could not cast from MissionBase to MissionIntel!");
    }
 public string GetNotes(MissionBase mission) => GetNotes(mission, "Mission");
Beispiel #55
0
 public bool HasNotes(MissionBase mission) {
     return HasNotes(mission, "Mission");
 }