public void onMissionActivated(MissionDetails missionDetails, GameObject availablePanel)
        {
            //remove the mission from available missions
            removeAvailableMission(missionDetails);

            //remove the available mission from view
            Destroy(availablePanel);

            //update the stored available mission json
            saveAvailableMissions();

            //get the current time in UTC
            DateTime timeNow = DateTime.UtcNow;

            //add the mission time to the current time to get the mission complete time
            DateTime completionTime = timeNow.AddSeconds(missionDetails.missionTime);

            //set up the deatils for the active mission (an object that can be serialized)
            ActiveMissionDetails activeMissionDetails = new ActiveMissionDetails(missionDetails, completionTime);

            //NEED TEAM INDEX BEFORE HERE
            int teamIndex = activeMissions.missions.Count;

            //add the active mission to storage
            addActiveMission(teamIndex, activeMissionDetails);

            //Debug.Log(activeMissionDetails.ToString());

            //create a new panel in the active panel view
            createActiveMissionPanel(teamIndex);
        }
        private void addActiveMission(int index, ActiveMissionDetails activeMissionDetails)
        {
            //add details to the ActiveMissions object
            activeMissions.missions.Add(index, activeMissionDetails);

            //save the current active missions object to storage
            //eventually move this to some type of saving functionality
            saveActiveMissions();
        }
        public void createActiveMissionPanel(int index)
        {
            //retrieve the active mission details using the team index
            ActiveMissionDetails activeMissionDetails = this.activeMissions.missions[index];

            //converts the string address to an integer array to be used with the sprite list
            int[] address = DestinationUtil.convertStringKeyToAddress(activeMissionDetails.missionDetails.destinationDetails.destinationDefinition.address);

            //instantiating the new active mission panel and adding to the view
            Transform activePanel = Instantiate(activeMissionPanel, Vector3.zero, Quaternion.identity).transform;

            activePanel.SetParent(activeMissionView, false);

            //add and set up the active mission object
            ActiveMission activeMission = (ActiveMission)activePanel.gameObject.AddComponent(typeof(ActiveMission));

            activeMission.initialise(activeMissionDetails);

            //Set the panel title to something meaningful
            string title = activeMissionDetails.missionDetails.missionDefinition.missionType.ToString() + " on " + activeMissionDetails.missionDetails.destinationDetails.destinationDefinition.designation;

            activePanel.Find("Title").GetComponent <Text>().text = title;

            //using the convert string address set all the address symbol images
            //possibly change this to be a new compoentn type for the class which sets the images up itself
            activePanel.Find("Symbol1").GetComponent <Image>().sprite = symbolSprites[address[0]];
            activePanel.Find("Symbol2").GetComponent <Image>().sprite = symbolSprites[address[1]];
            activePanel.Find("Symbol3").GetComponent <Image>().sprite = symbolSprites[address[2]];
            activePanel.Find("Symbol4").GetComponent <Image>().sprite = symbolSprites[address[3]];
            activePanel.Find("Symbol5").GetComponent <Image>().sprite = symbolSprites[address[4]];
            activePanel.Find("Symbol6").GetComponent <Image>().sprite = symbolSprites[address[5]];
            activePanel.Find("Symbol7").GetComponent <Image>().sprite = symbolSprites[address[6]];


            //set the pass rate text on the panel
            activePanel.Find("PassRate").GetComponent <Text>().text = "Pass Chance: " + (activeMissionDetails.missionDetails.passRate * 100) + "%";

            //add a new listener to the selection button for the panel which calls the onMissionActivated function
            //passing in the mission details for this mission
            activePanel.Find("SelectButton").GetComponent <Button>().onClick.AddListener(() => { onMissionCompleted(index, activePanel.gameObject); });
        }
Ejemplo n.º 4
0
    public void SetActiveMission()
    {
        GameObject ActiveMissionDetails;
        GameObject ImageActive;

        ActiveMissionDetails = GameObject.Find("ActiveMissionDetails");
        ImageActive          = GameObject.Find("ImageActive");

        foreach (var mission in ActiveMissionList)
        {
            if (mission.active == true)
            {
                ActiveMission = Resources.Load <Sprite>(mission.type);
                ImageActive.GetComponent <Image>().overrideSprite = ActiveMission;

                if (mission.type == "Kill")
                {
                    ActiveMissionDetails.GetComponent <Text>().text = mission.KillCount - mission.TotalKills + "/" + mission.KillCount +
                                                                      "\n" + mission.TargetType_Localised + " " + mission.TargetFaction;
                }
                if (mission.type == "Assassinate")
                {
                    ActiveMissionDetails.GetComponent <Text>().text = "Target system " + mission.DestinationSystem +
                                                                      "\n Kill " + mission.Target + " " + mission.TargetType_Localised;
                }
                if (mission.type == "Deliver Data")
                {
                    ActiveMissionDetails.GetComponent <Text>().text = "Deliver data to the " + mission.DestinationStation + " Station" +
                                                                      "\n In the " + mission.DestinationSystem + " system for the " + mission.TargetFaction;
                }
                if (mission.type == "Deliver")
                {
                    ActiveMissionDetails.GetComponent <Text>().text = "Deliver " + mission.KillCount + " " + mission.TargetType_Localised +
                                                                      "\n to " + mission.DestinationStation + " station for the " + mission.TargetFaction;
                }
                if (mission.type == "Disable")
                {
                    ActiveMissionDetails.GetComponent <Text>().text = "Disable the " + mission.TargetType_Localised;
                }
                if (mission.type == "Hack")
                {
                    ActiveMissionDetails.GetComponent <Text>().text = "Hack the " + mission.TargetType_Localised;
                }
                if (mission.type == "Mine")
                {
                    ActiveMissionDetails.GetComponent <Text>().text = "Mine " + mission.KillCount + " of " + mission.TargetType_Localised +
                                                                      "\n and deliver to " + mission.DestinationStation + " station for the " + mission.TargetFaction;
                }
                if (mission.type == "Source")
                {
                    ActiveMissionDetails.GetComponent <Text>().text = "Acquire " + mission.KillCount + " of " + mission.TargetType_Localised +
                                                                      "\n and deliver to " + mission.DestinationStation + " station for the " + mission.TargetFaction;
                }
                if (mission.type == "Salvage")
                {
                    ActiveMissionDetails.GetComponent <Text>().text = "Salvage " + mission.KillCount + " of " + mission.TargetType_Localised +
                                                                      "\n and deliver to " + mission.DestinationStation + " station for the " + mission.Faction;
                }
            }
        }
    }
 public void initialise(ActiveMissionDetails activeMissionDetails)
 {
     this.activeMissionDetails = activeMissionDetails;
     timeRemainingText         = this.transform.Find("TimeRemaining").GetComponent <Text>();
     selectButton = this.transform.Find("SelectButton").GetComponent <Button>();
 }