Beispiel #1
0
    void Shoot()
    {
        muzzeFlash.Play();

        if (Physics.Raycast(fpsCam.transform.position, fpsCam.transform.forward, out hit, range))
        {
            Debug.Log(hit.transform.name);
        }

        Enemys enemy = hit.transform.GetComponent <Enemys>();


        Target target = hit.transform.GetComponent <Target>();

        if (enemy != null)
        {
            enemy.TakeDamage(damage);
            if (audioclip != null)
            {
                AudioSource.PlayClipAtPoint(audioclip, transform.position);
            }
        }
        if (target != null)
        {
            target.TakeDamage(damage);
        }
        if (hit.rigidbody != null)
        {
            hit.rigidbody.AddForce(-hit.normal * impactForce);
        }
        impact = Instantiate(ImpactEffect, hit.point, Quaternion.LookRotation(hit.normal));
        Destroy(impact, 1f);
    }
Beispiel #2
0
    public GameObject MakeEnemy(Enemys enemy)
    {
        float Randomx = UnityEngine.Random.Range(new MapPosition().MinX, new MapPosition().MaxX);
        float Randomy = UnityEngine.Random.Range(new MapPosition().MinY, new MapPosition().MaxY);

        return(GameManager.Instantiate(EnemyList[enemy], new Vector3(Randomx, Randomy, 0), Quaternion.identity));
    }
Beispiel #3
0
        public void Test_Enemy()
        {
            Enemys lol    = new Enemys();
            string result = lol.AI_enemy("Normal");

            Assert.That(result, Is.EqualTo("Normal"));
        }
Beispiel #4
0
 void Start()
 {
     enemy     = GetComponent <Enemys>();
     score     = FindObjectOfType <Score>();
     spawnBord = GetComponent <SpawnBord>();
     animator  = GetComponent <Animator>();
 }
Beispiel #5
0
        public Unit GetRandomEnemy(bool mustFront)
        {
            if (!mustFront)
            {
                return(GetRandomEnemy());
            }
            var result = Enemys.FindAll(e => e.FrontUnit == null);

            return(this[result[_random.Next(result.Count - 1)].Index]);
        }
Beispiel #6
0
 public override void CreateEnemys()
 {
     Enemys.Add(new Slime());
     Enemys.Add(new Slime());
     Enemys.Add(new Slime());
     Enemys.Add(new Zombie());
     Enemys.Add(new Zombie());
     Enemys.Add(new Zombie());
     Enemys.Add(new Zombie());
 }
    void OnEnable()
    {
        _index = 0;
        if (e)
        {
            e = Resources.Load <Enemys>("Enemys");
        }

        else
        {
            e = ScriptableObject.CreateInstance <Enemys>();
            AssetDatabase.CreateAsset(e, "Assets/Resources/Enemys.asset");
            AssetDatabase.SaveAssets();
            AssetDatabase.Refresh();
        }
    }
	void OnEnable(){
		_index =0;
		if(e){

		e = Resources.Load<Enemys>("Enemys");
		}

		else {
			e = ScriptableObject.CreateInstance<Enemys>();
			AssetDatabase.CreateAsset (e, "Assets/Resources/Enemys.asset");
			AssetDatabase.SaveAssets();
			AssetDatabase.Refresh();
		}


	}
        private void timer_Tick(object sender, EventArgs e)
        {
            Canvas.SetLeft(player, playerLeftMargin);

            for (int i = 0; i < 10; i++)
            {
                float bulletYPos = (float)Canvas.GetBottom(Bullets[i]);
                float bulletXPos = (float)Canvas.GetLeft(Bullets[i]);
                if (bulletYPos > 0)
                {
                    Canvas.SetBottom(Bullets[i], bulletYPos + bulletSpeed);
                    if (bulletYPos > 620)
                    {
                        Canvas.SetBottom(Bullets[i], -100);
                    }
                    else
                    {
                        if (bulletYPos > 220 && bulletYPos < 220 + 280 && bulletXPos > 70 && bulletXPos < 70 + 420)
                        {
                            int row    = -1;
                            int column = -1;

                            row    = 3 - (int)((bulletYPos - 220f) / 70f);
                            column = (int)((bulletXPos - 70f) / 70f);

                            Image delEnemy = Enemys.FindName(string.Format("enemy{0}{1}", row, column)) as Image;

                            if (delEnemy.Width > 0)
                            {
                                delEnemy.Width = 0;
                                Canvas.SetBottom(Bullets[i], -100);
                                score += 10;
                                scoreDisplay.Content = score.ToString();
                            }
                        }

                        /*
                         *
                         * if (bulletYPos > 220 && bulletYPos < 220 + 70 && bulletXPos > 70 && bulletXPos < 70 + 70)
                         * {
                         *  Enemys.Children.Remove(enemy30);
                         * }
                         */
                    }
                }
            }
        }
Beispiel #10
0
    /// <summary>
    ///오브젝트 풀링할때 새로 생성하는 함수
    ///여기다가 추가옵션을 계속 넣어줘야된다.
    ///1. 생존여부
    ///2. uv 애니메이션
    ///3. 스텟
    ///4.애니메이션
    /// </summary>
    private Enemys CreateEnemey(EnemyInfo info)
    {
        Enemys newUnit = Instantiate(Resources.Load <GameObject>("Prefap/Unit/Enemy"), transform).GetComponent <Enemys>();

        newUnit.EnemyInfo      = info;
        newUnit.isDead         = true;
        newUnit.UVManager      = newUnit.GetComponentInChildren <UVManager>();
        newUnit.UVManager.Unit = newUnit;
        newUnit.unitType       = Unit.EUnitType.Enemy;
        newUnit.name           = "" + info.NameNumber;

        newUnit.Attack     = info.Attack;
        newUnit.AttackTime = info.AttackTime;
        newUnit.Defence    = info.Defence;
        newUnit.Resistance = info.Resistance;
        newUnit.MaxHp      = info.MaxHp;
        newUnit.NowHp      = info.NowHp;

        return(newUnit);
    }
Beispiel #11
0
        public Unit GetEnemyByWeapon(Weapon weapon)
        {
            if (weapon == Weapon.HuiLi)
            {
                var front = Enemys.FindAll(e => e.IsInFront).Count;
                var back  = Enemys.Count - front;
                return(front > back?Enemys.Find(e => e.IsInFront) : Enemys.Find(e => !e.IsInFront));
            }

            if (weapon == Weapon.Gong)
            {
                return(GetRandomEnemy());
            }

            if (weapon == Weapon.XiaoDao)
            {
                var target = Enemys.Find(e => e.FrontUnit != null);
                return(target ?? GetRandomEnemy());
            }

            return(GetRandomFrontEnemy());
        }
        private void Setting()
        {
            Images["bug"]    = new BitmapImage[4];
            Images["bug"][0] = new BitmapImage(new Uri("Asset/bug1.png", UriKind.Relative));
            Images["bug"][1] = new BitmapImage(new Uri("Asset/bug2.png", UriKind.Relative));
            Images["bug"][2] = new BitmapImage(new Uri("Asset/bug3.png", UriKind.Relative));
            Images["bug"][3] = new BitmapImage(new Uri("Asset/bug4.png", UriKind.Relative));

            Images["satellite"]    = new BitmapImage[4];
            Images["satellite"][0] = new BitmapImage(new Uri("Asset/satellite1.png", UriKind.Relative));
            Images["satellite"][1] = new BitmapImage(new Uri("Asset/satellite2.png", UriKind.Relative));
            Images["satellite"][2] = new BitmapImage(new Uri("Asset/satellite3.png", UriKind.Relative));
            Images["satellite"][3] = new BitmapImage(new Uri("Asset/satellite4.png", UriKind.Relative));

            Images["flyingsaucer"]    = new BitmapImage[4];
            Images["flyingsaucer"][0] = new BitmapImage(new Uri("Asset/flyingsaucer1.png", UriKind.Relative));
            Images["flyingsaucer"][1] = new BitmapImage(new Uri("Asset/flyingsaucer2.png", UriKind.Relative));
            Images["flyingsaucer"][2] = new BitmapImage(new Uri("Asset/flyingsaucer3.png", UriKind.Relative));
            Images["flyingsaucer"][3] = new BitmapImage(new Uri("Asset/flyingsaucer4.png", UriKind.Relative));

            Images["spaceship"]    = new BitmapImage[4];
            Images["spaceship"][0] = new BitmapImage(new Uri("Asset/spaceship1.png", UriKind.Relative));
            Images["spaceship"][1] = new BitmapImage(new Uri("Asset/spaceship2.png", UriKind.Relative));
            Images["spaceship"][2] = new BitmapImage(new Uri("Asset/spaceship3.png", UriKind.Relative));
            Images["spaceship"][3] = new BitmapImage(new Uri("Asset/spaceship4.png", UriKind.Relative));

            Images["star"]    = new BitmapImage[4];
            Images["star"][0] = new BitmapImage(new Uri("Asset/star1.png", UriKind.Relative));
            Images["star"][1] = new BitmapImage(new Uri("Asset/star2.png", UriKind.Relative));
            Images["star"][2] = new BitmapImage(new Uri("Asset/star3.png", UriKind.Relative));
            Images["star"][3] = new BitmapImage(new Uri("Asset/star4.png", UriKind.Relative));

            Images["watchit"]    = new BitmapImage[4];
            Images["watchit"][0] = new BitmapImage(new Uri("Asset/watchit1.png", UriKind.Relative));
            Images["watchit"][1] = new BitmapImage(new Uri("Asset/watchit2.png", UriKind.Relative));
            Images["watchit"][2] = new BitmapImage(new Uri("Asset/watchit3.png", UriKind.Relative));
            Images["watchit"][3] = new BitmapImage(new Uri("Asset/watchit4.png", UriKind.Relative));



            for (int i = 0; i < 4; i++)
            {
                for (int j = 0; j < 5; j++)
                {
                    EmemyArray[i, j] = Enemys.FindName(string.Format("enemy{0}{1}", i, j)) as Image;
                }
            }

            Canvas.SetLeft(player, playerLeftMargin);
            scoreDisplay.Content = score.ToString();

            for (int i = 0; i < 10; i++)
            {
                Bullets[i]        = new Rectangle();
                Bullets[i].Height = 20;
                Bullets[i].Width  = 5;
                Bullets[i].Fill   = new SolidColorBrush(System.Windows.Media.Colors.Yellow);
                Canvas.SetBottom(Bullets[i], -100);
                world.Children.Add(Bullets[i]);
            }

            Random random = new Random();

            for (int i = 0; i < 100; i++)
            {
                stars[i] = new Ellipse();
                int size = random.Next(1, 5);
                stars[i].Width  = size;
                stars[i].Height = size;
                stars[i].Fill   = new SolidColorBrush(Color.FromRgb(100, 100, 0));

                Canvas.SetLeft(stars[i], random.Next(0, 570));
                Canvas.SetBottom(stars[i], random.Next(0, 560));

                world.Children.Add(stars[i]);
            }
        }
Beispiel #13
0
 public void OnNewGame()
 {
     Enemys.ResetStaticVariables();
     SceneManager.LoadScene("lvl1");
 }
Beispiel #14
0
 public void OnMainMenu()
 {
     Enemys.ResetStaticVariables();
     SceneManager.LoadScene("MainMenu");
 }
Beispiel #15
0
        public void Generate(int level, Vector2 size)
        {
            if (!File.Exists("Content/Maps/level" + level + ".txt"))
            {
                level = 1;
            }
            string[] s = File.ReadAllLines("Content/Maps/level" + level + ".txt");
            int      x = 0, y = 0;

            foreach (string str in s)
            {
                foreach (char c in str)
                {
                    switch (c)
                    {
                    //Start Position
                    case '@':
                        backround.Add(new PassableBlock(Content.Load <Texture2D>("Textures/Blocks/MiscBlock1"), new Rectangle(x, y, (int)size.X, (int)size.Y)));
                        Start = new Vector2(x, y);
                        break;

                    // Exit
                    case 'E':
                        gameObjects.Add(new PassableBlock(Content.Load <Texture2D>("Textures/Blocks/MiscBlock1"), new Rectangle(x, y, (int)size.X, (int)size.Y)));
                        gameObjects.Add(new Exit(Content.Load <Texture2D>("Textures/Blocks/exit"), new Rectangle(x, y, (int)size.X, (int)size.Y * 2)));
                        break;

                    // Impassable Blocks
                    case 'X':
                        gameObjects.Add(new ImpassableBlock(Content.Load <Texture2D>("Textures/Blocks/Block1"), new Rectangle(x, y, (int)size.X, (int)size.Y)));
                        break;

                    case 'V':
                        gameObjects.Add(new ImpassableBlock(Content.Load <Texture2D>("Textures/Blocks/Block5"), new Rectangle(x, y, (int)size.X, (int)size.Y)));
                        break;

                    case 'F':
                        gameObjects.Add(new ImpassableBlock(Content.Load <Texture2D>("Textures/Blocks/Block8"), new Rectangle(x, y, (int)size.X, (int)size.Y)));
                        break;

                    case 'x':
                        gameObjects.Add(new ImpassableBlock(Content.Load <Texture2D>("Textures/Blocks/Block9"), new Rectangle(x, y, (int)size.X, (int)size.Y)));
                        break;

                    case 'Z':
                        gameObjects.Add(new ImpassableBlock(Content.Load <Texture2D>("Textures/Blocks/Block7"), new Rectangle(x, y, (int)size.X, (int)size.Y)));
                        break;

                    case 'Y':
                        gameObjects.Add(new ImpassableBlock(Content.Load <Texture2D>("Textures/Blocks/Block2"), new Rectangle(x, y, (int)size.X, (int)size.Y)));
                        break;

                    case 'D':
                        gameObjects.Add(new ImpassableBlock(Content.Load <Texture2D>("Textures/Blocks/Block3"), new Rectangle(x, y, (int)size.X, (int)size.Y)));
                        break;

                    case 'C':
                        gameObjects.Add(new ImpassableBlock(Content.Load <Texture2D>("Textures/Blocks/Block4"), new Rectangle(x, y, (int)size.X, (int)size.Y)));
                        break;

                    // Passable Blocks
                    case 'z':
                        backround.Add(new PassableBlock(Content.Load <Texture2D>("test"), new Rectangle(x, y, (int)size.X, (int)size.Y)));
                        break;

                    case '.':
                        backround.Add(new PassableBlock(Content.Load <Texture2D>("Textures/Blocks/MiscBlock1"), new Rectangle(x, y, (int)size.X, (int)size.Y)));
                        break;

                    case ',':
                        backround.Add(new PassableBlock(Content.Load <Texture2D>("Textures/Blocks/MiscBlock2"), new Rectangle(x, y, (int)size.X, (int)size.Y)));
                        break;

                    case 'o':
                        backround.Add(new PassableBlock(Content.Load <Texture2D>("Textures/Blocks/Block6"), new Rectangle(x, y, (int)size.X, (int)size.Y)));
                        break;

                    // Tourch
                    case 't':
                        gameObjects.Add(new PassableBlock(Content.Load <Texture2D>("Textures/Blocks/MiscTourch"), new Rectangle(x, y, (int)size.X, (int)size.Y)));
                        break;

                    // Spike Blocks
                    case 'S':
                        backround.Add(new PassableBlock(Content.Load <Texture2D>("Textures/Blocks/MiscBlock1"), new Rectangle(x, y, (int)size.X, (int)size.Y)));
                        gameObjects.Add(new SpikeBlock(Content.Load <Texture2D>("Textures/Blocks/SpikeBlock1"), new Rectangle(x, y, (int)size.X, (int)size.Y)));
                        break;

                    case 's':
                        backround.Add(new PassableBlock(Content.Load <Texture2D>("Textures/Blocks/MiscBlock1"), new Rectangle(x, y, (int)size.X, (int)size.Y)));
                        gameObjects.Add(new SpikeBlock(Content.Load <Texture2D>("Textures/Blocks/SpikeBlock2"), new Rectangle(x, y, (int)size.X, (int)size.Y)));
                        break;

                    // CheckPoint
                    case '#':
                        backround.Add(new PassableBlock(Content.Load <Texture2D>("Textures/Blocks/MiscBlock1"), new Rectangle(x, y, (int)size.X, (int)size.Y)));
                        gameObjects.Add((new CheckPoint(new Vector2(x, y), Content)));
                        break;

                    // Jug
                    case 'J':
                        gameObjects.Add(new Jug(new Vector2(x, y)));
                        backround.Add(new PassableBlock(Content.Load <Texture2D>("Textures/Blocks/MiscBlock1"), new Rectangle(x, y, (int)size.X, (int)size.Y)));
                        break;

                    // Armor
                    case 'A':
                        gameObjects.Add(new Armor(new Vector2(x, y)));
                        backround.Add(new PassableBlock(Content.Load <Texture2D>("Textures/Blocks/MiscBlock1"), new Rectangle(x, y, (int)size.X, (int)size.Y)));
                        break;

                    // HealthPoint
                    case 'H':
                        gameObjects.Add(new Health(new Vector2(x, y)));
                        backround.Add(new PassableBlock(Content.Load <Texture2D>("Textures/Blocks/MiscBlock1"), new Rectangle(x, y, (int)size.X, (int)size.Y)));
                        break;

                    // Potion
                    case '*':
                        gameObjects.Add(new Potion(new Vector2(x, y)));
                        backround.Add(new PassableBlock(Content.Load <Texture2D>("Textures/Blocks/MiscBlock1"), new Rectangle(x, y, (int)size.X, (int)size.Y)));
                        break;

                    // Bat
                    case 'B':
                        gameObjects.Add(new Bat(new Vector2(x, y)));
                        backround.Add(new PassableBlock(Content.Load <Texture2D>("Textures/Blocks/MiscBlock1"), new Rectangle(x, y, (int)size.X, (int)size.Y)));
                        break;

                    // MudMan
                    case 'M':
                        gameObjects.Add(new Mud(new Vector2(x, y)));
                        backround.Add(new PassableBlock(Content.Load <Texture2D>("Textures/Blocks/MiscBlock1"), new Rectangle(x, y, (int)size.X, (int)size.Y)));
                        break;

                    // Wolf
                    case 'W':
                        gameObjects.Add(new Wolf(new Vector2(x, y)));
                        backround.Add(new PassableBlock(Content.Load <Texture2D>("Textures/Blocks/MiscBlock1"), new Rectangle(x, y, (int)size.X, (int)size.Y)));
                        break;

                    // Raven
                    case 'R':
                        gameObjects.Add(new Raven(new Vector2(x, y)));
                        backround.Add(new PassableBlock(Content.Load <Texture2D>("Textures/Blocks/MiscBlock1"), new Rectangle(x, y, (int)size.X, (int)size.Y)));
                        break;

                    // Monke
                    case 'm':
                        gameObjects.Add(new Monkey(new Vector2(x, y)));
                        backround.Add(new PassableBlock(Content.Load <Texture2D>("Textures/Blocks/MiscBlock1"), new Rectangle(x, y, (int)size.X, (int)size.Y)));
                        break;

                    // Smoke
                    case 'K':
                        gameObjects.Add(new Smoke(new Vector2(x, y)));
                        backround.Add(new PassableBlock(Content.Load <Texture2D>("Textures/Blocks/MiscBlock1"), new Rectangle(x, y, (int)size.X, (int)size.Y)));
                        break;

                    // RedSkeleton
                    case 'T':
                        gameObjects.Add(new RedSkeleton(new Vector2(x, y)));
                        backround.Add(new PassableBlock(Content.Load <Texture2D>("Textures/Blocks/MiscBlock1"), new Rectangle(x, y, (int)size.X, (int)size.Y)));
                        break;

                    default:
                        break;
                    }
                    x    += (int)size.X;
                    width = System.Math.Max(x, width);
                }

                x      = 0;
                y     += (int)size.Y;
                height = System.Math.Max(y, height);
            }


            foreach (GameObject obj in gameObjects)
            {
                obj.Load(Content);
                if (obj is Block)
                {
                    blocks.Add((Block)obj);
                }
                else if (obj is CheckPoint)
                {
                    chekPoints.Add((CheckPoint)obj);
                }
                else if (obj is Enemy)
                {
                    Enemys.Add((Enemy)obj);
                }
                else if (obj is Item)
                {
                    items.Add((Item)obj);
                }
            }
        }
Beispiel #16
0
 //找到强力位敌人最多的目标
 public Unit GetCrossEnemy()
 {
     return(Enemys.OrderByDescending(f => f.CrossUnits.Count).FirstOrDefault());
 }
Beispiel #17
0
        protected override void Update(GameTime gameTime)
        {
            UpdateOption();
            currentPlayer.UpdateLevel(controles, animationList, Content);
            if (controles.Pause())
            {
                if (gameState == GameState.scenario || gameState == GameState.solo)
                {
                    oldGameState = gameState;
                    gameState    = GameState.pause;
                    pause        = new Pause(Content);
                }
                else if (gameState == GameState.pause || gameState == GameState.multiPause)
                {
                    gameState = oldGameState;
                }
                else if (gameState == GameState.creation)
                {
                    currentPlayer.newChar = false;
                    SavPerso obj = new SavPerso();
                    currentPlayer.Serialize(obj);
                    System.Xml.Serialization.XmlSerializer writer2 = new System.Xml.Serialization.XmlSerializer(typeof(SavPerso));
                    System.IO.StreamWriter file2 = new System.IO.StreamWriter((Environment.GetFolderPath(Environment.SpecialFolder.Personal) + "/TDZ/Sauvegardes/") + currentPlayer.name);
                    writer2.Serialize(file2, obj);
                    file2.Close();
                    gameState      = GameState.menu;
                    menu.menuState = MenuState.main;
                    menu           = new Menu(Content, GraphicsDevice);
                }
                else if (gameState == GameState.menu)
                {
                    gameState = GameState.menu;
                    menu      = new Menu(Content, GraphicsDevice);
                }
                else if (gameState == GameState.multi)
                {
                    oldGameState = gameState;
                    gameState    = GameState.multiPause;
                    pause        = new Pause(Content);
                }
                else
                {
                    gameState      = GameState.menu;
                    menu.menuState = MenuState.main;
                    menu           = new Menu(Content, GraphicsDevice);
                    sound.soundPlayer.Stop();
                    menu.LaunchMenuSound(sound);
                }
            }

            //Events States Mouse and Keyboard

            msg = "";

            switch (gameState)
            {
            case GameState.solo:

                sound.UpdateMusic();
                destrucTileList = new List <Vector3>();
                players[hostPlayer].Update(animationList);
                Player1Events.CheckEvents(players[hostPlayer], mapWorld, destrucTileList, hostPlayer, shotsPlayer, sound, ref msg, controles, entityList, animationList, particlesEngineList, Content, explosionReseau);
                Player1Events.MouseEvents(players[hostPlayer], shotsPlayer, camera, sound, controles, animationList, particlesEngineList);
                shotsPlayer.Update(animationList);
                UpdateItem();
                UpdateExplosion();
                UpdateAnimation();
                Reset();
                UpdateParticleEngine();

                #region IA Update

                if (!currentPlayer.God)
                {
                    for (int i = 0; i < Enemys.Count; i++)
                    {
                        Enemys[i].shotsIA.otherTirList = new List <Tirs>();
                        Enemys[i].shotsIA.otherTirList = shotsPlayer.tirList;
                        for (int j = 0; j < Enemys[i].shotsIA.tirList.Count; j++)
                        {
                            shotsPlayer.otherTirList.Add(Enemys[i].shotsIA.tirList[j]);
                        }
                    }

                    for (int i = 0; i < Enemys.Count; i++)
                    {
                        IA.IACheckEvents(Enemys[i], IAType.Survival, mapWorld, players, Enemys[i].shotsIA, destrucTileList, hostPlayer, sound, entityList, animationList, particlesEngineList, Content, Enemys, explosionReseau);
                        LoadSurvival(Enemys);
                    }

                    for (int i = 0; i < Enemys.Count; i++)
                    {
                        Enemys[i].shotsIA.Update(animationList);
                    }
                }

                #endregion IA Update

                mapWorld.Update();
                camera.UpdateCentered(players, hostPlayer, scaleNormValue, GraphicsDevice, controles);
                break;

            case GameState.pause:
                pause.Update(mouseCoef, controles);
                if (pause.menu)
                {
                    gameState      = GameState.menu;
                    menu.menuState = MenuState.main;
                    menu           = new Menu(Content, GraphicsDevice);
                    sound.soundPlayer.Stop();
                    menu.LaunchMenuSound(sound);
                }
                else if (pause.resumeGame)
                {
                    gameState = oldGameState;
                }
                break;

            case GameState.scenario:
                sound.UpdateMusic();

                solo.Update(players[hostPlayer], mapWorld);
                if (solo.levelUp)
                {
                    solo = new Solo(solo.currentLevel, solo.player);
                    LoadContent();
                }
                if (currentPlayer.lifes < 1)
                {
                    gameState = GameState.gameOver;
                }
                players[hostPlayer].Update(animationList);
                Player1Events.CheckEvents(players[hostPlayer], mapWorld, destrucTileList, hostPlayer, shotsPlayer, sound, ref msg, controles, entityList, animationList, particlesEngineList, Content, explosionReseau);
                Player1Events.MouseEvents(players[hostPlayer], shotsPlayer, camera, sound, controles, animationList, particlesEngineList);
                shotsPlayer.Update(animationList);
                UpdateItem();
                UpdateExplosion();
                UpdateAnimation();
                Reset();
                UpdateParticleEngine();
                if (!currentPlayer.God)
                {
                    for (int i = 0; i < Enemys.Count; i++)
                    {
                        Enemys[i].shotsIA.otherTirList = new List <Tirs>();
                        Enemys[i].shotsIA.otherTirList = shotsPlayer.tirList;
                        for (int j = 0; j < Enemys[i].shotsIA.tirList.Count; j++)
                        {
                            shotsPlayer.otherTirList.Add(Enemys[i].shotsIA.tirList[j]);
                        }
                    }

                    for (int i = 0; i < Enemys.Count; i++)
                    {
                        IA.IACheckEvents(Enemys[i], IAType.patr_Snd, mapWorld, players, Enemys[i].shotsIA, destrucTileList, hostPlayer, sound, entityList, animationList, particlesEngineList, Content, Enemys, explosionReseau);
                        if (!Enemys[i].IsAlive)
                        {
                            entityList.Remove(Enemys[i]);
                            Enemys.RemoveAt(i);
                        }
                    }

                    for (int i = 0; i < Enemys.Count; i++)
                    {
                        Enemys[i].shotsIA.Update(animationList);
                    }
                }

                mapWorld.Update();
                camera.UpdateCentered(players, hostPlayer, scaleNormValue, GraphicsDevice, controles);
                break;

            case GameState.multi:
                sound.UpdateMusic();
                destrucTileList = new List <Vector3>();
                players[hostPlayer].Update(animationList);
                Player1Events.CheckEvents(players[hostPlayer], mapWorld, destrucTileList, hostPlayer, shotsPlayer, sound, ref msg, controles, entityList, animationList, particlesEngineList, Content, explosionReseau);
                Player1Events.MouseEvents(players[hostPlayer], shotsPlayer, camera, sound, controles, animationList, particlesEngineList);
                //Player1Events.SurvivalLvL0 = Player1Events.killplayer0 / 50;
                UpdateParticleEngine();
                shotsPlayer.Update(animationList);
                UpdateExplosion();
                UpdateItem();
                UpdateAnimation();
                Reset();
                camera.UpdateCentered(players, hostPlayer, scaleNormValue, GraphicsDevice, controles);
                bool flagCapture = false;
                if (client.mode == ModeMulti.ctf)
                {
                    foreach (Flag flag in flags)
                    {
                        flagCapture = flag.Update(players[hostPlayer], mapWorld);
                    }
                }
                UpdateNetwork(flagCapture);
                break;

            case GameState.multiPause:

                sound.UpdateMusic();
                destrucTileList = new List <Vector3>();
                players[hostPlayer].Update(animationList);
                Player1Events.CheckEvents(players[hostPlayer], mapWorld, destrucTileList, hostPlayer, shotsPlayer, sound, ref msg, controles, entityList, animationList, particlesEngineList, Content, explosionReseau);
                Player1Events.MouseEvents(players[hostPlayer], shotsPlayer, camera, sound, controles, animationList, particlesEngineList);
                //Player1Events.SurvivalLvL0 = Player1Events.killplayer0 / 50;
                UpdateParticleEngine();
                shotsPlayer.Update(animationList);
                UpdateExplosion();
                UpdateItem();
                UpdateAnimation();
                Reset();
                camera.UpdateCentered(players, hostPlayer, scaleNormValue, GraphicsDevice, controles);
                flagCapture = false;
                if (client.mode == ModeMulti.ctf)
                {
                    foreach (Flag flag in flags)
                    {
                        flagCapture = flag.Update(players[hostPlayer], mapWorld);
                    }
                }
                UpdateNetwork(flagCapture);
                pause.Update(mouseCoef, controles);
                if (pause.menu)
                {
                    for (int i = 0; i < players[hostPlayer].ItemList.Count; i++)
                    {
                        if (players[hostPlayer].ItemList[i].type == objectType.flag)
                        {
                            players[hostPlayer].ItemList[i].isOnMap            = true;
                            ((Flag)players[hostPlayer].ItemList[i]).isCaptured = false;
                            mapWorld.itemList.Add(players[hostPlayer].ItemList[i]);
                            players[hostPlayer].ItemList.RemoveAt(i);
                            break;
                        }
                    }
                    client.SendExit(hostPlayer);
                    gameState      = GameState.menu;
                    menu.menuState = MenuState.main;
                    menu           = new Menu(Content, GraphicsDevice);
                    sound.soundPlayer.Stop();
                    menu.LaunchMenuSound(sound);
                }
                else if (pause.resumeGame)
                {
                    gameState = oldGameState;
                }
                break;

            case GameState.menu:
                menu.Update(ref gameState, mouseCoef, Content, ref fullScreenON, ref soundON, sound, controles);

                if (gameState == GameState.exit)
                {
                    Opt option = new Opt();
                    option.Fullscreen         = fullScreenON;
                    option.SoundOn            = soundON;
                    option.controleTab        = controles.controleTab;
                    option.name               = currentPlayer.name;
                    option.language           = Langage.langueactuelle;
                    option.masterServerAdress = ConnectMaster.MasterIPAdress;
                    System.Xml.Serialization.XmlSerializer writer = new System.Xml.Serialization.XmlSerializer(typeof(Opt));
                    System.IO.StreamWriter file = new System.IO.StreamWriter((Environment.GetFolderPath(Environment.SpecialFolder.Personal) + "/TDZ/Options/OptionMenu"));
                    writer.Serialize(file, option);
                    file.Close();

                    SavPerso obj = new SavPerso();
                    currentPlayer.Serialize(obj);
                    System.Xml.Serialization.XmlSerializer writer2 = new System.Xml.Serialization.XmlSerializer(typeof(SavPerso));
                    System.IO.StreamWriter file2 = new System.IO.StreamWriter((Environment.GetFolderPath(Environment.SpecialFolder.Personal) + "/TDZ/Sauvegardes/") + currentPlayer.name);
                    writer2.Serialize(file2, obj);
                    file2.Close();

                    Exit();
                }
                if (gameState == GameState.multi || gameState == GameState.solo || gameState == GameState.editor || gameState == GameState.scenario)
                {
                    LoadContent();
                }

                break;

            case GameState.creation:
                menu.gestion.Update(ref currentPlayer, mouseCoef, controles, Content, GraphicsDevice);
                break;

            default:
                break;
            }

            //Save old Events State

            base.Update(gameTime);
        }
Beispiel #18
0
 public void RestartLevel()
 {
     Time.timeScale = 1.0f;
     Enemys.ResetStaticVariables();
     SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
 }
Beispiel #19
0
        protected override Composite CreateBehavior()
        {
            return(_root ?? (_root =
                                 new PrioritySelector(
                                     new Decorator(
                                         ret => !_isBehaviorDone,
                                         new PrioritySelector(
                                             new Decorator(ret => Me.QuestLog.GetQuestById((uint)QuestId) != null && Me.QuestLog.GetQuestById((uint)QuestId).IsCompleted,
                                                           new Sequence(
                                                               new Action(ret => TreeRoot.StatusText = "Finished!"),
                                                               new WaitContinue(120,
                                                                                new Action(delegate
            {
                _isBehaviorDone = true;
                return RunStatus.Success;
            }))
                                                               )),

                                             new Decorator(
                                                 ret => Students.Count == 0,
                                                 new PrioritySelector(
                                                     new Decorator(ret => !AtFirstPoint,
                                                                   new PrioritySelector(
                                                                       new Decorator(ret => Me.Location.Distance(StudentPoints[0]) > 3,
                                                                                     new Action(ret => Navigator.MoveTo(StudentPoints[0]))),
                                                                       new Decorator(ret => Me.Location.Distance(StudentPoints[0]) <= 3,
                                                                                     new Action(ret => AtFirstPoint = true))
                                                                       )),
                                                     new Decorator(ret => AtFirstPoint,
                                                                   new PrioritySelector(
                                                                       new Decorator(ret => Me.Location.Distance(StudentPoints[1]) > 3,
                                                                                     new Action(ret => Navigator.MoveTo(StudentPoints[1]))),
                                                                       new Decorator(ret => Me.Location.Distance(StudentPoints[1]) <= 3,
                                                                                     new Action(ret => AtFirstPoint = false))
                                                                       ))

                                                     )),

                                             new Decorator(ret => Students.Count > 0 && Students[0].IsDead,
                                                           new DecoratorIsNotPoiType(PoiType.Kill,
                                                                                     new PrioritySelector(
                                                                                         new Decorator(ret => Enemys.Any(enem => enem.Location.Distance(Students[0].Location) < 20),
                                                                                                       new ActionSetPoi(ret => new BotPoi(Enemys.Where(enem => enem.Location.Distance(Students[0].Location) < 20).OrderBy(enem => enem.Distance).FirstOrDefault(), PoiType.Kill))),
                                                                                         new Decorator(ret => Students[0].Distance > 3,
                                                                                                       new Action(ret => Navigator.MoveTo(Students[0].Location)))))),

                                             new Decorator(ret => EnemysStudents.Count > 0,
                                                           new PrioritySelector(
                                                               new Decorator(ret => EnemysStudents[0].Distance > 10,
                                                                             new Action(ret => Navigator.MoveTo(EnemysStudents[0].Location))),
                                                               new Decorator(ret => EnemysStudents[0].Distance <= 10 && Me.IsMoving,
                                                                             new Action(ret => WoWMovement.MoveStop())),
                                                               new Decorator(ret => EnemysStudents[0].Distance <= 10,
                                                                             new PrioritySelector(
                                                                                 new Decorator(ret => RoutineManager.Current.CombatBehavior != null,
                                                                                               RoutineManager.Current.PullBehavior),
                                                                                 new Action(ret => EnemysStudents[0].Target()),
                                                                                 new Action(c => RoutineManager.Current.Pull()))))),

                                             new Decorator(ret => Students.Count > 0 && Students[0].IsAlive,
                                                           new PrioritySelector(
                                                               new Decorator(ret => Students.Any(stud => stud.Combat) && EnemysStudents.Count > 0,
                                                                             new ActionSetPoi(ret => new BotPoi(EnemysStudents[0], PoiType.Kill))),
                                                               new Decorator(ret => Students[0].Distance > 3,
                                                                             new Action(ret => Navigator.MoveTo(Students[0].Location)))))


                                             )))));
        }
Beispiel #20
0
    void Update()
    {
        if (pause)
        {
            PauseSet();
        }
        else
        {
            PauseUnSet();
        }
        CameraMove();
        ClearCheck = Clear();
        if (GameOver())
        {
            GameoverUI.SetActive(true);
        }
        else if (ClearCheck && Stage == 1)
        {
            ClearUI.SetActive(true);
            BossBonusText.enabled = false;
            EnemyAllkillReward    = (WaveSpawner.WaveIndex * EnemyKillReward);
            Balance += bonusreward;

            Balance += EnemyAllkillReward;
            BonusRewardtext.text        = bonusreward.ToString();
            EnemyDestoryRewardtext.text = EnemyAllkillReward.ToString();
            WaveSpawner.wavecnt         = 0;
            ClearCheck = false;
        }
        else if (ClearCheck && Stage == 2)
        {
            ClearUI.SetActive(true);
            BossBonusText.enabled = true;
            EnemyAllkillReward    = (WaveSpawner.WaveIndex * EnemyKillReward);
            Balance += bonusreward;
            Balance += EnemyAllkillReward;
            BonusRewardtext.text        = (bonusreward + MiddleBossBonusBalance).ToString();
            EnemyDestoryRewardtext.text = EnemyAllkillReward.ToString();
            BossBonusText.text          = "중간보스 : " + MiddleBossBonusBalance.ToString();
            WaveSpawner.wavecnt         = 0;
            ClearCheck = false;
        }
        else if (ClearCheck && Stage == 3)
        {
            ClearUI.SetActive(true);
            BossBonusText.enabled = true;
            EnemyAllkillReward    = (WaveSpawner.WaveIndex * EnemyKillReward);
            Balance += bonusreward;
            Balance += EnemyAllkillReward;
            Balance += FinalBossBonusBalance;
            BonusRewardtext.text        = (bonusreward + FinalBossBonusBalance).ToString();
            EnemyDestoryRewardtext.text = EnemyAllkillReward.ToString();
            BossBonusText.text          = "최종보스 : " + FinalBossBonusBalance.ToString();
            WaveSpawner.wavecnt         = 0;
            ClearCheck = false;
        }
        else if (Shop)
        {
            ShopUI.SetActive(true);
            TurretStrtext.text = Turret.STR.ToString();
            turretDeftext.text = Turret.DEF.ToString();
        }
        else if (!SHOP)
        {
            ShopUI.SetActive(false);
        }
        if (!ClearCheck)
        {
            BalanceText.text = "남은돈 : " + Balance.ToString();
        }
        if (4 < WaveSpawner.WavesCnt && WaveSpawner.WavesCnt < 5 && Stage == 2)
        {
            enemys = Enemys.MIDDLEBOSS;
        }
        else if (Stage == 3 && WaveSpawner.WaveIndex <= 5 && WaveSpawner.WavesCnt == 5)
        {
            enemys = Enemys.FINALBOSS;
        }
    }
Beispiel #21
0
        public void Setup()
        {
            string[] gunnames = new string[] { "Excalibur", "Glock", "Assualt Rifle"
                                               , "Red John", "Heaven Bringer", "Glory", "Lucy" };
            string[] swordnames = new string[] { "Champion", "Wooden sword", "Stormbringer"
                                                 , "Mournblade", "Sword of Dawn", "RavenBrand", "Harry" };
            string[] armournames = new string[] { "Hide Armour", "Iron Armour", "Elestial Armour"
                                                  , "Windbreaker", "A Sheet", "A leaf", "Diamond Glades" };

            // be mindfull of the size of the arrays, as they need to be equal length
            if (gunnames.Length - swordnames.Length != 0)
            {
                throw new ArgumentOutOfRangeException();
            }
            if (gunnames.Length - armournames.Length != 0)
            {
                throw new ArgumentOutOfRangeException();
            }

            ItemFactory fact = new ItemFactory();

            for (int i = 0; i < gunnames.Length; i++)
            {
                //var gun = fact.CreateItem<Gun>();
                //allItems.Add(gunnames[i], gun);
                //allItems[gunnames[i]].Name = gunnames[i];
                ////AllItems.Add(gun);
                //var sword = fact.CreateItem<Sword>();
                //allItems.Add(swordnames[i], sword);
                //allItems[swordnames[i]].Name = swordnames[i];
                ////AllItems.Add(sword);
                //var armour = fact.CreateItem<Clothing>();
                //allItems.Add(armournames[i], armour);
                //allItems[armournames[i]].Name = armournames[i];
                ////AllItems.Add(armour);

                Item gun = new Gun(gunnames[i]);
                AllItems.Add(gun.Name, gun);
                Item sword = new Sword(swordnames[i]);
                AllItems.Add(sword.Name, sword);
                Item armour = new Clothing(armournames[i]);
                AllItems.Add(armour.Name, armour);
            }

            //var fist = fact.CreateItem<Sword>();
            Item fist = new Weapon("Fist");

            AllItems.Add("Fist", fist);

            Player.MakeItem(AllItems["Fist"]);
            Player.EquipItem(AllItems["Fist"]);

            Player.EquipItem(AllItems["Hide Armour"]);

            Console.WriteLine(Player.EquipedWeapon.ToString());

            AllResources.Add(new Resource("Wood"));  // for home / defence
            AllResources.Add(new Resource("Iron"));  // make weapons / clothes
            AllResources.Add(new Resource("Grain")); // for the citizens
            AllResources.Add(new Resource("Wool"));  // for clothes
            AllResources.Add(new Resource("Stone")); // for home / defence

            string[] enemyList = { "Rebelious Farmer", "Giant Wolf", "Lost Knight", "Sneaky Ninja", "Slow Oger", "Swift Reeves", "Mad Scientist" };

            for (int i = 0; i < enemyList.Length; i++)
            {
                int damageRandom = rand.Next(1, 51);
                Enemys.Add(new Enemy(enemyList[i], damageRandom));
            }

            GenerateMap();
        }
Beispiel #22
0
 public void GoToMainMenu()
 {
     Time.timeScale = 1.0f;
     Enemys.ResetStaticVariables();
     SceneManager.LoadScene("MainMenu");
 }