Пример #1
0
    //private GroceryStore _GroceryStore;

    void Awake()
    {
        _Zombies = gameObject.GetComponent <Zombies> ();


        //_GroceryStore = GameObject.Find ("GroceryStore").GetComponent<GroceryStore>();
    }
Пример #2
0
        public void Update(GameTime gameTime)
        {
            if (aliveZombies + deadZombies < maxZombies)
            {
                spawnTimer += gameTime.ElapsedGameTime.Milliseconds;

                if (spawnTimer >= spawnTime)
                {
                    spawnTimer = 0;

                    Vector2 position = GetNewPosition();

                    int     ranIndex = handler.GetRandom(0, zombiePool.Length - 1);
                    Zombies zombie   = zombiePool[ranIndex];

                    AddZombie(zombie, position);
                }
            }

            /*//All zombies dead
             * if(deadZombies == maxZombies)
             * {
             *  if(!infinity && wave < maxWaves)
             *  {
             *      SetWave(wave + 1);
             *  }
             * }*/
        }
Пример #3
0
            //This checks the collision of the other object.
            void OnCollisionEnter(Collision other)
            {
                //It says here that if other collides with the citizen object then...
                if (other.gameObject.GetComponent <Citizen>())
                {
                    //Citizen c is the same as the other object with the citizen component
                    Citizen c = other.gameObject.GetComponent <Citizen>();
                    //Zombies z equals object c.
                    Zombies z = c;

                    //After the zombiefication the amount of zombies is increased by 1 and the citizen amount is reduced by one
                    Instancias.totalZombiesStatic += 1;
                    Instancias.totalCitizenStatic -= 1;
                }

                //We check if the collision is with the bullet

                if (other.gameObject.name == ("Bullet(Clone)"))
                {
                    //the health of the zombie is reduced by the bullet damage
                    zInformation.Health -= Instancias.BulletDamageStatic;
                    //Debug.Log(zInformation.Health);

                    //If the zombie's health is 0 or less the destroyed function is called.
                    if (zInformation.Health <= 0)
                    {
                        destroyed();
                    }
                }
            }
Пример #4
0
        public void Simulate(Stopwatch sw, int processingTime)
        {
            for (int i = 0; i < rand.Next(0, 3); i++)
            {
                Ash.Pos = Ash.Pos.Move(Util.ToRadians(rand.Next(0, 360)), rand.Next(0, 1000));
                SimulateTurn();

                if (!Humans.Any() || !Zombies.Any() || sw.ElapsedMilliseconds >= processingTime)
                {
                    return;
                }
            }

            var targetZ = Zombies[rand.Next(0, Zombies.Length - 1)];

            while (Humans.Any() && Zombies.Any() && sw.ElapsedMilliseconds < processingTime)
            {
                if (!Zombies.Any(z => z.Id == targetZ.Id))
                {
                    targetZ = Zombies[rand.Next(0, Zombies.Length - 1)];
                }
                int distance = Ash.Pos.DistanceTo(targetZ.NextPos);
                distance = distance > 3000 ? 1000 : rand.Next(distance - 2000, 1000);

                Ash.Pos = Ash.Pos.MoveToward(targetZ.NextPos, distance);
                SimulateTurn();
            }
        }
Пример #5
0
        private void AddZombie(Zombies zombie, Vector2 position)
        {
            aliveZombies++;

            switch (zombie)
            {
            case Zombies.ZombieDog:
                handler.GetEntityManager().Add(new ZombieDog(Assets.zombieDog, handler, position));
                break;

            case Zombies.Zombie1:
                handler.GetEntityManager().Add(new Zombie(Assets.zombie1, handler, position));
                break;

            case Zombies.Zombie2:
                handler.GetEntityManager().Add(new Zombie(Assets.zombie2, handler, position));
                break;

            case Zombies.Zombie3:
                handler.GetEntityManager().Add(new Zombie(Assets.zombie3, handler, position));
                break;

            case Zombies.Zombie4:
                handler.GetEntityManager().Add(new Zombie(Assets.zombie4, handler, position));
                break;
            }
        }
Пример #6
0
 public override void Draw()
 {
     Background.Draw();
     Functions.DrawObjects();
     Zombies.Draw();
     Players.Draw();
 }
Пример #7
0
 void Update()
 {
     for (int i = 0; i < zombies.Length; i++)
     {
         Zombies.ZombMove(zombies[i], zombies[i].GetComponent <Zombies>().state);
     }
 }
Пример #8
0
        protected override void Collided(Zombies.Zombie zombie)
        {
            Zombies.Impacts.Cold cold = new Zombies.Impacts.Cold(this.Game, 3000, this.slowDown);
            zombie.AddImpact(cold);

            base.Collided(zombie);
        }
Пример #9
0
        public void SetHumansOrZombies <T>(List <T> objects)
        {
            var isHumans = false;

            if (typeof(T) == typeof(Human))
            {
                isHumans = true;
                Humans   = new List <Human>();
            }
            else if (typeof(T) == typeof(Zombie))
            {
                Zombies = new List <Zombie>();
            }

            foreach (T obj in objects)
            {
                if (isHumans)
                {
                    Humans.Add(new Human((obj as Human)));
                }
                else
                {
                    Zombies.Add(new Zombie((obj as Zombie)));
                }
            }
        }
Пример #10
0
        public override void Update()
        {
            const float MAX_STEP = 1 / 30f;

            Data.World.Step(MathF.Min(Time.DeltaTime, MAX_STEP));
            Zombies.Update();
            Players.Update();
            Camera.FollowPlayer();
        }
Пример #11
0
 void Awake()
 {
     //these componenents are all located within this game object so i can just use getcomponent
     PlayerCam    = Camera.main;
     _GameState   = gameObject.GetComponent <GameState>();
     _Movement    = gameObject.GetComponent <Movement> ();
     _Zombies     = gameObject.GetComponent <Zombies> ();
     _ItemActions = gameObject.GetComponent <ItemActions> ();
 }
Пример #12
0
        // public bool Disconnected { get; private set; }



        public Zombie(string ip, int port, Socket socket)
        {
            IP     = ip;
            Port   = port;
            Socket = socket;

            App.Current.Dispatcher.Invoke(() =>
            {
                Zombies.Add(this);
            });
        }
Пример #13
0
    void Awake()
    {
        _Zombies   = GameObject.Find("GameFlow").GetComponent <Zombies> ();
        _GameState = GameObject.Find("GameFlow").GetComponent <GameState> ();


        modelPanel = ModelPanel.Instance();

//		myYesAction = new UnityAction (ZombieYesFunction);
//		myNoAction = new UnityAction (ZombieNoFunction);
//		myCancelAction = new UnityAction (ZombieCancelFunction);
    }
Пример #14
0
        public void Destroy()
        {
            //  Disconnected = true;

            App.Current.Dispatcher.Invoke(() =>
            {
                Server.ClearRequests();
                Zombies.Remove(this);
            });

            Disconnected?.Invoke(this, EventArgs.Empty);
        }
Пример #15
0
        public override void Open()
        {
            ClearColour = new Color(0f, .1f, .05f, 1f);

            Players.Init(1);
            Players.InsertLocal(Players.GetFreeID());

            Zombies.Load();

            Functions.LoadLevel(LevelType.Level1);
            Background.Setup();
            Players.Bodies[Players.LocalID].Position = Functions.ToSim(Data.PlayerSpawnPoint);
            Camera.Position = Functions.FromSim(Players.Bodies[Players.LocalID].Position);
        }
Пример #16
0
    private void StartGame()
    {
        _PanelGameOver.SetActive(false);
        _PanelInstructions.SetActive(false);
        _PanelTraining.SetActive(true);
        _MainCamera.transform.position = _CameraStartPosition;
        if (Zombies.Count != 0)
        {
            foreach (GameObject zombie in Zombies)
            {
                Destroy(zombie);
            }
            Zombies.Clear();
        }
        if (Squad.Count != 0)
        {
            foreach (GameObject man in Squad)
            {
                Destroy(man);
            }
            Squad.Clear();
        }
        Loss            = false;
        MissionComplete = false;
        _Player         = Instantiate(_PlayerPref, new Vector3(0, 0, 0), Quaternion.identity);
        _Player.GetComponent <Player>().gm         = this;
        _Player.GetComponent <Player>().MainCamera = _MainCamera;
        _Player.GetComponent <Player>().Radio      = _Radio;
        _Player.GetComponent <Player>().Aim        = _Aim;
        Squad.Add(_Player);

        GameObject Sniper = Instantiate(_SniperPref, new Vector3(0, 0, -2f), Quaternion.identity);

        Sniper.GetComponent <Sniper>().Player = _Player;
        Sniper.GetComponent <Sniper>().gm     = this;
        Squad.Add(Sniper);

        GameObject TommyGunner = Instantiate(_TommyGunnerPref, new Vector3(1.63f, 0, -2f), Quaternion.identity);

        TommyGunner.GetComponent <TommyGunner>().Player = _Player;
        TommyGunner.GetComponent <TommyGunner>().gm     = this;
        Squad.Add(TommyGunner);

        GameObject MachineGunner = Instantiate(_MachineGunnerPref, new Vector3(-1.63f, 0, -2f), Quaternion.identity);

        MachineGunner.GetComponent <MachineGunner>().Player = _Player;
        MachineGunner.GetComponent <MachineGunner>().gm     = this;
        Squad.Add(MachineGunner);
    }
Пример #17
0
        public override void Open()
        {
            Camera.Position = Vector2.Zero;

            Players.Init(1);
            Players.InsertLocal(Players.GetFreeID());

            Zombies.Load();
            Functions.LoadLevel(LevelType.Level1);
            Background.Setup();
            Players.Bodies[Players.LocalID].Position = Functions.ToSim(Data.PlayerSpawnPoint);
            Camera.Position = Functions.FromSim(Players.Bodies[Players.LocalID].Position);

            Label_CurrentLayer = new UI_Label(Enum.GetNames(typeof(Layers))[(byte)Layer], Color.White, new Vector2(12, 6), Data.SmallFont, false);
        }
Пример #18
0
        public void SitOut(PlayerInfo p)
        {
            if (!Seats.Players().ContainsPlayerWithSameName(p))
            {
                return;
            }

            var seat = p.NoSeat;

            if (!Zombies.Contains(p))
            {
                Zombies.Add(p);
            }
            p.NoSeat           = -1;
            Seats[seat].Player = null;
        }
Пример #19
0
        public void Simulate(Stopwatch sw, int processingTime)
        {
            var targetZ = Zombies[rand.Next(0, Zombies.Length - 1)];

            while (Humans.Any() && Zombies.Any() && sw.ElapsedMilliseconds < processingTime)
            {
                if (!Zombies.Any(z => z.Id == targetZ.Id))
                {
                    targetZ = Zombies[rand.Next(0, Zombies.Length - 1)];
                }
                int distance = Ash.Pos.DistanceTo(targetZ.NextPos);
                distance = distance > 3000 ? 1000 : rand.Next(distance - 2000, 1000);

                var angle = Util.ToDegrees(Util.AngleBetween(Ash.Pos, targetZ.NextPos));
                angle  += rand.Next(-10, 10);
                Ash.Pos = Ash.Pos.Move(Util.ToRadians(angle), distance);
                SimulateTurn();
            }
        }
Пример #20
0
 void Update()
 {
     if (Play)
     {
         if (Loss)
         {
             Play = false;
             _PanelGameOver.SetActive(true);
         }
         else if (MissionComplete)
         {
             _PanelMissionComplete.SetActive(true);
             Play = false;
         }
         if (Input.GetAxis("Mouse ScrollWheel") != 0)
         {
             AttackPosture        = !AttackPosture;
             _AttackImage.enabled = AttackPosture;
             _MovingImage.enabled = !AttackPosture;
         }
         if (Mathf.Abs(_Player.transform.position.z - _MainCamera.transform.position.z - 12) > 7 || Mathf.Abs(_Player.transform.position.x - _MainCamera.transform.position.x) > 15)
         {
             _CameraDestination = new Vector3(_Player.transform.position.x, _MainCamera.transform.position.y, _Player.transform.position.z - 10);
         }
         if (_MainCamera.transform.position != _CameraDestination)
         {
             _MainCamera.transform.position = Vector3.MoveTowards(_MainCamera.transform.position, _CameraDestination, _MainCameraSpeed * Time.deltaTime);
         }
         if (Time.time - _LastSpawnTime > _TimeBetweenSpawn && Zombies.Count < _MaxNumberZombiesOnMap)
         {
             float      RadiusSpawn   = Random.Range(60, 200);
             float      AngleSpawn    = Random.Range(-Mathf.PI, Mathf.PI);
             Vector3    positionSpawn = new Vector3(_Player.transform.position.x + RadiusSpawn * Mathf.Sin(AngleSpawn), 0, _Player.transform.position.z + RadiusSpawn * Mathf.Cos(AngleSpawn));
             GameObject SpawnZombie   = Instantiate(_Zombie, positionSpawn, Quaternion.identity);
             Zombies.Add(SpawnZombie);
             SpawnZombie.GetComponent <Zombie>().gm = this;
             _LastSpawnTime = Time.time;
         }
     }
 }
Пример #21
0
        public void SetHumansOrZombies <T>(List <T> objects)
        {
            if (typeof(T) == typeof(Human))
            {
                Humans = new List <Human>();
            }
            if (typeof(T) == typeof(Zombie))
            {
                Zombies = new List <Zombie>();
            }

            foreach (T obj in objects)
            {
                if (obj is Human)
                {
                    Humans.Add(new Human((obj as Human)));
                }

                if (obj is Zombie)
                {
                    Zombies.Add(new Zombie((obj as Zombie)));
                }
            }
        }
Пример #22
0
 // Do something when collision happened
 protected virtual void Collided(Zombies.Zombie zombie)
 {
     Zombies.Impacts.Damaging dam = new Zombies.Impacts.Damaging(this.Game, this.damage);
     zombie.AddImpact(dam);
     BulletEffect();
 }
Пример #23
0
 // Ajoute un zombie à la listede zombies existants
 public void AddZombie(int id, Zombie zomb)
 {
     Zombies.Add(id, zomb);
 }
Пример #24
0
 // Nettoie les listes de zombies et humains
 public void Clear()
 {
     Zombies.Clear();
     Humans.Clear();
 }