示例#1
0
 public void CopyRoomObjects(RoomObj room)
 {
     foreach (var current in room.TerrainObjList)
     {
         TerrainObjList.Add(current.Clone() as TerrainObj);
     }
     foreach (var current2 in room.GameObjList)
     {
         GameObjList.Add(current2.Clone() as GameObj);
     }
     foreach (var current3 in room.DoorList)
     {
         var doorObj = current3.Clone() as DoorObj;
         doorObj.Room = this;
         DoorList.Add(doorObj);
     }
     foreach (var current4 in room.EnemyList)
     {
         EnemyList.Add(current4.Clone() as EnemyObj);
     }
     foreach (var current5 in room.BorderList)
     {
         BorderList.Add(current5.Clone() as BorderObj);
     }
 }
示例#2
0
 private void Start()
 {
     currentRoom    = gameObject.transform.parent;
     isPlayerInRoom = currentRoom.GetComponentInParent <RoomTriggerCollider>();
     enemyList      = GameObject.FindGameObjectWithTag("Enemy List").GetComponent <EnemyList>();
     Invoke("SpawnEnemy", waitTime);
 }
示例#3
0
 /// <summary>
 /// Start is called on the frame when a script is enabled just before
 /// any of the Update methods is called the first time.
 /// </summary>
 public override void Start()
 {
     entityType = Type.Player;
     sound      = GetComponent <AudioSource>();
     el         = GameObject.Find("Enemies").GetComponent <EnemyList>();
     DontDestroyOnLoad(gameObject);
 }
 public void OnDestroy()
 {
     if (LevelManager.Instance != null && !LevelManager.Instance.IsPaused)
     {
         EnemyList.DestroyEnemy(this);
     }
 }
示例#5
0
 void removeObject()
 {
     EnemyList.RemoveAll(checkExist);
     ItemList.RemoveAll(checkExist);
     TamaList.RemoveAll(checkExist);
     EffectList.RemoveAll(checkExist);
 }
示例#6
0
    private IEnumerator SpawnEnemy()
    {
        if (currentSpawnTime > spawnDelay)
        {
            currentSpawnTime = 0;

            if (EnemyList.Count < currentLevel)
            {
                Vector3    spawnPoint   = spawnPoints[Random.Range(0, spawnPoints.Length)].transform.position;
                GameObject enemyToSpawn = enemies[Random.Range(0, enemies.Length)];
                Instantiate(enemyToSpawn);
                enemyToSpawn.transform.position = spawnPoint;
            }
        }

        if (RoundKills == EnemyList.Count && EnemyList.Count > 0 && currentLevel != finalLevel)
        {
            EnemyList.Clear();
            RoundKills = 0;
            yield return(new WaitForSeconds(3f));

            currentLevel++;
            levelText.text = "Level " + currentLevel;
        }

        if (RoundKills == finalLevel)
        {
            StartCoroutine(EndGame("Victory!"));
        }

        yield return(null);

        StartCoroutine(SpawnEnemy());
    }
示例#7
0
    void spawnEnemy()
    {
        if (canSpawn)
        {
            dist = Vector2.Distance(player.position, spawnPos);
            RaycastHit2D hit = Physics2D.Raycast(spawnPos, (player.position - (Vector3)spawnPos).normalized, dist, collisionMask);

            if (!hit)
            {
                GameObject enemy = EnemyList.getEnemy();
                if (enemy != null)
                {
                    Instantiate(enemy, spawnPos, Quaternion.identity);
                    Invoke("spawnEnemy", GlobalStats.spawnRate);
                }
            }
            else
            {
                Invoke("spawnEnemy", 1);
            }
        }
        else
        {
            Invoke("spawnEnemy", 1);
        }
    }
示例#8
0
    void Start()
    {
        if (GameController.mapIsDone == true)
        {
            TM = GameObject.FindGameObjectWithTag("TileMap").GetComponent <TileMap>();
            //Get the loaded enemylist from resources
            EnemyList eList = EnemyList.GetEnemyList();

            // Randomise enemies
            EnemyControl.Randomise();
            if (eList != null)
            {
                GameObject SelectedModel = eList.GetRelevantModel(EnemyControl.enemyClass);
                if (SelectedModel != null)
                {
                    Vector3 NewPos = transform.position + transform.up * (transform.lossyScale.y * 0.5f);
                    selectedEnemy = GameObject.Instantiate(SelectedModel, NewPos, transform.rotation) as GameObject;

                    if (selectedEnemy != null)
                    {
                        if (selectedEnemy.GetComponent <EnemyUnit>() != null)
                        {
                            selectedEnemy.GetComponent <EnemyUnit>().map = TM;
                            float PositionOffset = TM.tileSize / 2.0f;
                            selectedEnemy.GetComponent <EnemyUnit>().SetSpawnLocation((int)((NewPos.x - PositionOffset) / TM.tileSize), (int)((NewPos.z - PositionOffset) / TM.tileSize));
                        } //if
                    }     //if
                }         //if
            }             //if
        }                 //if
    }                     //Start
示例#9
0
        /// <summary>
        /// Load graphics content for the game.
        /// </summary>
        public override void LoadContent()
        {
            if (content == null)
            {
                content = new ContentManager(ScreenManager.Game.Services, "Content");
            }

            gameFont = content.Load <SpriteFont>("gamefont");
            // Create a new SpriteBatch, which can be used to draw textures.
            viewportRect = new Rectangle(0, 0,
                                         (int)(this.ScreenManager.GraphicsDevice.Viewport.Width * .75f),
                                         this.ScreenManager.GraphicsDevice.Viewport.Height);
            enemyFieldBound = new Rectangle(
                -(int)(this.ScreenManager.GraphicsDevice.Viewport.Width * .25f),
                -(int)(this.ScreenManager.GraphicsDevice.Viewport.Height * .25f),
                (int)(this.ScreenManager.GraphicsDevice.Viewport.Width * 1.5f),
                (int)(this.ScreenManager.GraphicsDevice.Viewport.Height * 1.5f));

            if (enemies == null)
            {
                enemies = new EnemyList(content);
            }
            if (foods == null)
            {
                foods = new FoodList(content);
            }
            if (stage == null)
            {
                stage = new Stage1(content, this.ScreenManager.GraphicsDevice, enemies);
            }
            if (player1 == null)
            {
                player1 = new PlayerCharacter(
                    content.Load <Texture2D>("PC\\player_flying"),
                    content.Load <Texture2D>("PC\\player_death"),
                    content.Load <Texture2D>("Bullets\\fireball0001"),
                    content.Load <Texture2D>("Food\\foodgauge"),
                    content.Load <Texture2D>("Food\\foodbar"),
                    viewportRect);
                player1.LoadSounds(content);
            }
            healthBarBG   = content.Load <Texture2D>("Enemies\\healthBar");
            healthBarFill = content.Load <Texture2D>("Enemies\\healthBarFill");
            UIFont        = content.Load <SpriteFont>("UI");

            // A real game would probably have more content than this sample, so
            // it would take longer to load. We simulate that by delaying for a
            // while, giving you a chance to admire the beautiful loading screen.
            Thread.Sleep(1000);
            backgroundMusic = content.Load <SoundEffect>("Sounds\\backgroundmusic");

            instance          = backgroundMusic.CreateInstance();
            instance.IsLooped = true;
            instance.Play();

            // once the load has finished, we use ResetElapsedTime to tell the game's
            // timing mechanism that we have just finished a very long frame, and that
            // it should not try to catch up.
            ScreenManager.Game.ResetElapsedTime();
        }
示例#10
0
 protected override void Detect()
 {
     base.Detect();
     //防御姿态主动时攻击
     if (m_defStatus == objDefStatus.initiative && EnemyList.Count > 0)
     {
         //this.Log("目标对象:" + EnemyList[0]);
         if (EnemyList[0] == null)
         {
             //清理空对象
             EnemyList.RemoveAt(0);
             //停止状态
             m_status = objStatus.empty;
             return;
         }
         else
         {
             GameManager.instance.CmdOrder = false;
             AttackPoint(EnemyList[0].transform.position, objStatus.Attack);
             if (isMine && ReportTime <= 0)
             {
                 //汇报
                 string str = string.Format("{0}:与敌方目标<color=#FFAF23>{1}</color>发生交战!", Name, EnemyList[0].Name);
                 MessageSystemMag.instance.AddMessage(str);
                 ReportTime = 30;
             }
         }
     }
 }
示例#11
0
        /// <summary>
        /// Representing the first wave.
        /// </summary>
        /// <returns></returns>
        bool Wave1()
        {
            if (EnemyList.Count != 0)
            {
                if (counter >= 15)
                {
                    EnemyBulletList.Add(new Bullet.HPP(new Vector2(rand.Next(1024), 0), new Vector2(0, 2)));
                    EnemyBulletList.Add(new Bullet.Clear(new Vector2(rand.Next(1024), 0), new Vector2(0, 4)));
                    EnemyBulletList.Add(new Bullet.Cross(new Vector2(rand.Next(1024), 0), new Vector2(0, 3)));

                    if (rand.NextDouble() <= 0.05)
                    {
                        EnemyBulletList.Add(new Bullet.Life(new Vector2(rand.Next(1024), 0), new Vector2(0, 5)));
                    }

                    counter = 0;
                }

                counter++;
                return(false);
            }
            else
            {
                counter = 0;

                for (int i = 630; i <= 1200; i += 100)
                {
                    EnemyList.Add(new Enemy.Seahorse(this, 300, i));
                    EnemyList.Add(new Enemy.Seahorse(this, 824, i));
                }

                return(true);
            }
        }
示例#12
0
        bool Wave2()
        {
            if (counter >= 10)
            {
                EnemyBulletList.Add(new Bullet.Add(new Vector2(rand.Next(1024), 10), new Vector2(0, rand.Next(3, 6)), true));
                counter = 0;
            }

            counter++;

            if (EnemyList.Count == 0)
            {
                EnemyList.Add(new Enemy.VerticalSaucer(this, new Vector2(612, 300), 1074, true));
                EnemyList.Add(new Enemy.VerticalSaucer(this, new Vector2(412, 300), 1074, true));
                EnemyList.Add(new Enemy.HorizontalSaucer(this, new Vector2(300, 400), -25, true));
                EnemyList.Add(new Enemy.HorizontalSaucer(this, new Vector2(512, 200), -25, true));
                EnemyList.Add(new Enemy.HorizontalSaucer(this, new Vector2(624, 100), -25, true));

                EnemyList.Add(new Enemy.EvilEel2(this, 100));
                EnemyList.Add(new Enemy.EvilEel2(this, 1124, 200));
                EnemyList.Add(new Enemy.EvilEel2(this, 1224, 300));
                EnemyList.Add(new Enemy.EvilEel2(this, 1324, 400));
                EnemyList.Add(new Enemy.EvilEel2(this, 1424, 500));

                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#13
0
        bool Wave5()
        {
            if (EnemyList.Count != 0)
            {
                if (counter >= 30)
                {
                    for (int i = 0; i <= 5; i++)
                    {
                        EnemyBulletList.Add(new Bullet.HPP(new Vector2(rand.Next(1024), 0), new Vector2(0, rand.Next(5))));
                        EnemyBulletList.Add(new Bullet.HPP(new Vector2(rand.Next(1024), 0), new Vector2(0, rand.Next(5))));
                        EnemyBulletList.Add(new Bullet.HPP(new Vector2(rand.Next(1024), 0), new Vector2(0, rand.Next(5))));
                        EnemyBulletList.Add(new Bullet.Clear(new Vector2(rand.Next(1024), 0), new Vector2(0, rand.Next(5))));
                    }
                    counter = 0;
                }

                counter++;
                return(false);
            }
            else
            {
                for (int i = 100; i <= 550; i += 80)
                {
                    EnemyList.Add(new Enemy.Smiley(this, 1300, i));
                }
                counter = 0;
                return(true);
            }
        }
示例#14
0
        bool Wave5()
        {
            if (EnemyList.Count == 0)
            {
                EnemyList.Add(new Enemy.Epsilon(this, 50, true));
                EnemyList.Add(new Enemy.Epsilon(this, 974, false));
                EnemyList.Add(new Enemy.Delta(this, 100, true));
                EnemyList.Add(new Enemy.Delta(this, 550, false));
                return(true);
            }
            else
            {
                if (counter >= 55)
                {
                    EnemyBulletList.Add(new Bullet.Add(new Vector2(rand.Next(1024), 620), new Vector2(1, -2)));
                    EnemyBulletList.Add(new Bullet.Add(new Vector2(rand.Next(1024), 30), new Vector2(1, 1), true));
                    EnemyBulletList.Add(new Bullet.HPP(new Vector2(rand.Next(1024), 30), new Vector2(1, 3)));

                    EnemyBulletList.Add(new Bullet.Garble(new Vector2(rand.Next(1024), 620), new Vector2(-1.5f, -3)));

                    counter = 0;
                }
                counter++;

                return(false);
            }
        }
示例#15
0
        bool Wave1()
        {
            if (EnemyList.Count == 0)
            {
                EnemyList.Add(new Enemy.VerticalSaucer(this, new Vector2(256, 200), 0, false));
                EnemyList.Add(new Enemy.VerticalSaucer(this, new Vector2(512, 200), 0, false));
                EnemyList.Add(new Enemy.VerticalSaucer(this, new Vector2(768, 200), 0, false));
                counter = 0;
                return(true);
            }

            if (counter >= 40)
            {
                for (int i = 0; i <= 10; i++)
                {
                    EnemyBulletList.Add(new Bullet.HPP(new Vector2(rand.Next(1024), 10), new Vector2(0, rand.Next(3, 6))));
                }

                EnemyBulletList.Add(new Bullet.Add(new Vector2(rand.Next(1024), 10), new Vector2(0, rand.Next(3, 6))));
                EnemyBulletList.Add(new Bullet.Add(new Vector2(rand.Next(1024), 10), new Vector2(0, rand.Next(3, 6)), true));
                counter = 0;
            }

            counter++;

            return(false);
        }
示例#16
0
    void Update()
    {
        if (m_lifeAtZero)
        {
            return;
        }

        float height = m_spriteLife.size.y;

        int life = EnemyList.getSumLife();

        m_spriteLife.size = new Vector2(life / (float)m_totalLife * m_initialWidth, height);

        if (life <= 0)
        {
            m_lifeAtZero = true;

            Event <BossKilledEvent> .Broadcast(new BossKilledEvent());

            DOVirtual.DelayedCall(m_hideTime, () =>
            {
                if (this == null)
                {
                    return;
                }
                gameObject.SetActive(false);
            });
        }
    }
示例#17
0
 public void Reset()
 {
     ItemList.Clear();
     EnemyList.Clear();
     BlockList.Clear();
     BackgroundList.Clear();
 }
示例#18
0
        bool Wave9()
        {
            if (EnemyList.Count != 0)
            {
                if (counter >= 50)
                {
                    EnemyBulletList.Add(new Bullet.HPP(new Vector2(rand.Next(1024), 0), new Vector2(0, rand.Next(4))));
                    EnemyBulletList.Add(new Bullet.Clear(new Vector2(rand.Next(1024), 0), new Vector2(0, rand.Next(4))));
                    counter = 0;
                }

                counter++;

                if (counter2 >= 200)
                {
                    EnemyBulletList.Add(new Bullet.Life(new Vector2(1054, rand.Next(50, 600)), new Vector2(-3, 0)));
                    counter2 = 0;
                }

                counter2++;

                return(false);
            }
            else
            {
                EnemyList.Add(new Enemy.TrackingShooterFish3(this, 325));
                return(true);
            }
        }
示例#19
0
    public static int CalculateEXP(int playerLevel, int enemyLevel, EnemyList enemy, float modifier = 1f)
    {
        int   levelDiff     = enemyLevel - playerLevel;
        float levelModifier = 1 + 0.015f * levelDiff;

        return(Mathf.RoundToInt(BaseEXPChart[enemy] * 1f * 1f));
    }
示例#20
0
        bool Wave3()
        {
            if (EnemyList.Count != 0)
            {
                if (counter >= 15)
                {
                    EnemyBulletList.Add(new Bullet.HPP(new Vector2(rand.Next(1024), 630), new Vector2(0, -2)));
                    EnemyBulletList.Add(new Bullet.Clear(new Vector2(rand.Next(1024), 630), new Vector2(0, -2)));

                    if (rand.NextDouble() <= 0.01)
                    {
                        EnemyBulletList.Add(new Bullet.Life(new Vector2(rand.Next(1024), 0), new Vector2(0, 5)));
                    }

                    counter = 0;
                }

                counter++;
                return(false);
            }
            else
            {
                EnemyList.Add(new Enemy.Kitty1(this));
                return(true);
            }
        }
示例#21
0
    public object GetEnemyJson()
    {
        string    jsonString  = File.ReadAllText(Application.dataPath + "/Resources/Data/Enemy.json");
        EnemyList skillObject = JsonMapper.ToObject <EnemyList>(jsonString);

        return(skillObject);
    }
示例#22
0
    public void ReloadLevel()
    {
        IsPaused    = true;
        isReloading = true;
        EnemyList.Clear();
        DeserializeLevelData();
        SetActiveFunction(doorList);
        SetParallax();

        /*finalGhostObjects = ghostObjects;
         * for (int i = 0; i < ghostObjects.Count; i++)
         *  Destroy(ghostObjects[i].gameObject);
         * ghostObjects.Clear();
         * if (isGhostReplayActive)
         * {
         *  if (!hasBeenInit)
         *  {
         *      hasBeenInit = true;
         *      InitialzeGhostPlayer();
         *      //player.GetComponent<PlayerController>().inputScript.Reset();
         *  }
         * }*/
        System.GC.Collect();
        System.GC.WaitForPendingFinalizers();
    }
示例#23
0
        /// <summary>
        /// Checks if an enemy has reached the bottom of the screen
        /// </summary>
        public bool HasReachedBottom()
        {
            // Create a new bool for the return value
            bool retVal = false;

            // Go through every enemy on the enemy list
            for (int i = EnemyList.Count - 1; i >= 0; i--)
            {
                // If it has reached the bottom
                if (EnemyList[i].Coordinates.Y > BOTTOM_BOUDARY)
                {
                    // Delete that enemy
                    EnemyList[i].Delete();

                    // Remove it from the list
                    EnemyList.Remove(EnemyList[i]);

                    // Sets the return value to true
                    retVal = true;
                }
            }

            // Return `reVal`
            return(retVal);
        }
示例#24
0
        /// <summary>
        /// Checks if an enemy was hit by a bullet
        /// </summary>
        /// <param name="bulletCoordinate">The coordinate of the bullet</param>
        /// <returns>If there was a hit</returns>
        public bool CheckHit(Vector2 bulletCoordinate, out Vector2 coordinate)
        {
            coordinate = new Vector2(0, 0);

            // Go through all existing enemies
            for (int i = EnemyList.Count - 1; i >= 0; i--)
            {
                // Save the coordinate on a specific variable
                coordinate = EnemyList[i].Coordinates;

                // If the bullet hit an enemy
                if (bulletCoordinate.X >= coordinate.X + 1 &&
                    bulletCoordinate.X < coordinate.X + 6 &&
                    bulletCoordinate.Y >= coordinate.Y &&
                    bulletCoordinate.Y < coordinate.Y + 2)
                {
                    // Delete the enemy
                    EnemyList[i].Delete();

                    // Remove the enemy from the list
                    EnemyList.Remove(EnemyList[i]);

                    // Return true
                    return(true);
                }
            }

            // Return false
            return(false);
        }
示例#25
0
    void Start()
    {
        waveList  = Resources.Load <WaveList>("WaveList");
        enemyList = Resources.Load <EnemyList>("EnemyList");

        UpdateEnemiesThisWave();
        InitWave();
    }
示例#26
0
 void Start()
 {
     StockGuestImageLists();
     nameText       = this.transform.Find("NameText").GetComponent <Text>();
     enemyThumbnail = this.transform.Find("EnemyThumbnail").GetComponent <Image>();
     outline        = this.GetComponent <Outline>();
     enemyList      = this.transform.parent.GetComponent <EnemyList>();
 }
 private void Awake()
 {
     player    = Player.instance();
     comp      = GameObject.Find("Companion").GetComponent <Companion>();
     lastSpawn = new Enemy[spawnPoints.Length];
     el        = GameObject.Find("Enemies").GetComponent <EnemyList>();
     op        = GameObject.Find("EnemyPool").GetComponent <ObjectPooler>();
 }
示例#28
0
    public static EnemyList Create()
    {
        EnemyList asset = ScriptableObject.CreateInstance <EnemyList>();

        AssetDatabase.CreateAsset(asset, "Assets/Resources/EnemyList.asset");
        AssetDatabase.SaveAssets();
        return(asset);
    }
    public void StartEditor()
    {
        m_PropList = new PropList();
        m_PropList.Initialize();

        m_EnemyList = new EnemyList();
        m_EnemyList.Initialize();
    }
示例#30
0
 private void Enemy_OnDie(Character obj)
 {
     EnemyList.Remove(obj);
     activeCharacters.Remove(obj);
     pooledCharacters.Enqueue(obj);
     obj.gameObject.SetActive(false);
     obj.Init();
 }
示例#31
0
 public void Awake()
 {
     Instance = this;
 }
示例#32
0
 public void OnDestroy()
 {
     Instance = null;
 }