Esempio n. 1
0
        public override void Serialize(GenericWriter writer)
        {
            base.Serialize(writer);

            var version = writer.SetVersion(1);

            switch (version)
            {
            case 1:
                writer.WriteBlock(w => w.WriteType(Missions, t => Missions.Serialize(w)));
                goto case 0;

            case 0:
            {
                writer.WriteBlock(w => w.WriteType(Broadcasts, t => Broadcasts.Serialize(w)));
                writer.WriteBlock(w => w.WriteType(Locations, t => Locations.Serialize(w)));
                writer.WriteBlock(w => w.WriteType(Restrictions, t => Restrictions.Serialize(w)));
                writer.WriteBlock(w => w.WriteType(Rewards, t => Rewards.Serialize(w)));
                writer.WriteBlock(w => w.WriteType(Rules, t => Rules.Serialize(w)));
                writer.WriteBlock(w => w.WriteType(Sounds, t => Sounds.Serialize(w)));
                writer.WriteBlock(w => w.WriteType(SuddenDeath, t => SuddenDeath.Serialize(w)));
                writer.WriteBlock(w => w.WriteType(Timing, t => Timing.Serialize(w)));
                writer.WriteBlock(w => w.WriteType(Weather, t => Weather.Serialize(w)));
            }
            break;
            }
        }
Esempio n. 2
0
 public override void Reset()
 {
     Broadcasts.Reset();
     Locations.Reset();
     Restrictions.Reset();
     Rewards.Reset();
     Rules.Reset();
     Sounds.Reset();
     SuddenDeath.Reset();
     Timing.Reset();
     Weather.Reset();
 }
Esempio n. 3
0
 public override void Clear()
 {
     Broadcasts.Clear();
     Locations.Clear();
     Restrictions.Clear();
     Rewards.Clear();
     Rules.Clear();
     Sounds.Clear();
     SuddenDeath.Clear();
     Timing.Clear();
     Weather.Clear();
 }
Esempio n. 4
0
    // Use this for initialization
    void Start()
    {
        neutralAI          = GetComponent <NeutralAI>();
        assignUnits        = GetComponent <AssignUnits> ();
        suddenDeath        = GetComponent <SuddenDeath>();
        conflictResolution = GetComponent <ConflictResolution>();
        timerText          = GameObject.Find("TurnTimerText").GetComponent <Text>();
        sections           = GameObject.Find("Sectors").GetComponentsInChildren <Section>();

        if (Data.IsDemo)
        {
            StartCoroutine("DemoModeRoutine");
        }
        if (Data.GameFromLoaded)
        {
            // Restores the current turn value
            SetTurn(SaveGameHandler.loadedGame.CurrentTurn);
        }
    }
Esempio n. 5
0
    void Update()
    {
        if (Players.Count == 0 || SceneManager.GetActiveScene().name != "GameScene")
        {
            return;
        }
        bool            GameOver   = false;
        HashSet <Teams> aliveTeams = new HashSet <Teams>();

        foreach (PlayerData p in Players)
        {
            if (p.IsDead == false)
            {
                aliveTeams.Add(p.Team);
            }
        }
        if (aliveTeams.Count() == 1)
        {
            if (aliveTeams.First() == Teams.NoTeam && Players.FindAll(x => x.IsDead == false).Count <= 1)
            {
                GameOver = true;
            }
            else if (aliveTeams.First() != Teams.NoTeam)
            {
                GameOver = true;
            }
        }
        if (Players.FindAll(x => x.IsDead == false).Count <= 1)
        {
            GameOver = true;
        }
        if (GameOver)
        {
            waitForGameOver -= Time.deltaTime;
            if (waitForGameOver > 0)
            {
                return;
            }
            List <PlayerData> pds = Players.FindAll(x => x.IsDead == false);
            //pds.ForEach(x => x.numberOfWins++);
            if (pds.Count > 0)
            {
                pds[0].numberOfWins++;
            }
            foreach (PlayerData pd in Players)
            {
                pd.gameObject.SetActive(false);
            }
            SceneManager.LoadScene("ScoreScene");
        }
        if (SuddenDeathTimer > 0)
        {
            if (SuddenDeathTimer < Mathf.Min(30, SuddenDeathTimerStart / 3))
            {
                if (playedHurryUpWarning == false)
                {
                    playedHurryUpWarning = true;
                    GetComponent <AudioSource>().PlayOneShot(hurryUpSuddenDeathClip);
                }
            }
            SuddenDeathTimer -= Time.deltaTime;
        }
        else
        {
            if (suddenDeath == null)
            {
                suddenDeath = Instantiate(suddenDeathPrefab);
            }
        }
    }
Esempio n. 6
0
 void Start()
 {
     _suddenDeath = FindObjectOfType<SuddenDeath>();
     //_timeCount = GameObject.Find("Time").GetComponent<TimeCount>();
     _actionManager = FindObjectOfType<KeyAction>();
 }
Esempio n. 7
0
        public override void Serialize(GenericWriter writer)
        {
            base.Serialize(writer);

            int version = writer.SetVersion(0);

            switch (version)
            {
            case 0:
            {
                writer.WriteBlock(
                    () => writer.WriteType(
                        Broadcasts,
                        t =>
                    {
                        if (t != null)
                        {
                            Broadcasts.Serialize(writer);
                        }
                    }));

                writer.WriteBlock(
                    () => writer.WriteType(
                        Locations,
                        t =>
                    {
                        if (t != null)
                        {
                            Locations.Serialize(writer);
                        }
                    }));

                writer.WriteBlock(
                    () => writer.WriteType(
                        Restrictions,
                        t =>
                    {
                        if (t != null)
                        {
                            Restrictions.Serialize(writer);
                        }
                    }));

                writer.WriteBlock(
                    () => writer.WriteType(
                        Rewards,
                        t =>
                    {
                        if (t != null)
                        {
                            Rewards.Serialize(writer);
                        }
                    }));

                writer.WriteBlock(
                    () => writer.WriteType(
                        Rules,
                        t =>
                    {
                        if (t != null)
                        {
                            Rules.Serialize(writer);
                        }
                    }));

                writer.WriteBlock(
                    () => writer.WriteType(
                        Sounds,
                        t =>
                    {
                        if (t != null)
                        {
                            Sounds.Serialize(writer);
                        }
                    }));

                writer.WriteBlock(
                    () => writer.WriteType(
                        SuddenDeath,
                        t =>
                    {
                        if (t != null)
                        {
                            SuddenDeath.Serialize(writer);
                        }
                    }));

                writer.WriteBlock(
                    () => writer.WriteType(
                        Timing,
                        t =>
                    {
                        if (t != null)
                        {
                            Timing.Serialize(writer);
                        }
                    }));

                writer.WriteBlock(
                    () => writer.WriteType(
                        Weather,
                        t =>
                    {
                        if (t != null)
                        {
                            Weather.Serialize(writer);
                        }
                    }));
            }
            break;
            }
        }
Esempio n. 8
0
 void Start()
 {
     _suddenDeath = FindObjectOfType <SuddenDeath>();
     //_timeCount = GameObject.Find("Time").GetComponent<TimeCount>();
     _actionManager = FindObjectOfType <KeyAction>();
 }