public void SetEnemies(float _x, float _y, float _xScale, float _yScale, float _speed, Color _color, int _health, int _level, bool _alive, int _value, GameObject _Target)
    {
        name   = "Enemy_R";      //Default enemies are red
        xPos   = _x;
        yPos   = _y;
        xScale = _xScale;
        yScale = _yScale;
        speed  = _speed;
        color  = _color;
        Health = _health;
        Level  = _level;
        alive  = _alive;
        value  = _value;
        Target = _Target;

        transform.localRotation = Quaternion.identity;        //Reset rotation
        if (Level <= 1)
        {
            GetComponent <Renderer>().material.color = EnemyType [0];           //Spawn only reds in level 1
        }
        if (Level == 2)
        {
            GetComponent <Renderer>().material.color = EnemyType [Random.Range(0, 2)];             //red and green
        }
        if (Level > 2)
        {
            GetComponent <Renderer>().material.color = EnemyType [2];           // red green and yellow
        }

        //ENEMY TYPES

        if (GetComponent <Renderer>().material.color == EnemyType [1])
        {
            name   = "Enemy_G";
            color  = EnemyType[1];
            Health = 3;
            speed  = Random.Range(0.11f, 0.15f);
            value  = 25;
        }
        //Lock on
        if (GetComponent <Renderer>().material.color == EnemyType [2])
        {
            name  = "Enemy_Y";
            color = EnemyType[2];
            speed = Random.Range(0.13f, 0.15f);
            value = 20;
        }
        LoadParticles(transform.position, color, speed, 5, transform);                  //Once everything is set, create particles for each ship

        xPos = Random.Range(ScreenWidthLeft + xScale, ScreenWidthRight);                //Spawns objects in range of -8, 8 as ints
        yPos = ScreenHeight + yScale;                                                   // Spawns above range of bullets
        Vector3 pos = new Vector3(Mathf.Round((xPos - xScale / 2) * 10) / 10, yPos, 0); // so to prevent spawning of screen the equation is My spawn areaa(pos)-half of the enemies widthx-xscale/2, then add its size again to keep it going 1 left and push it 1 right

        transform.position = pos;
        Vector3 scale = new Vector3(xScale, yScale, 0.1f);

        transform.localScale = scale;
        Targetlocked         = false;
        EnemiesList.Add(gameObject);
    }
 private void Start()
 {
     particleEmmitersController = GameObject.Find("ParticleEmmiters").GetComponent <ParticleEmmitersController>();
     player        = GameObject.Find("Player").GetComponent <PlayerController>();
     enemiesList   = GameObject.Find("Enemies").GetComponent <EnemiesList>();
     gridTransform = GetComponent <GridTransform>();
 }
        void Test_Start()
        {
            DrillRocketUnused  = 5;
            ReturnRocketUnused = 2;

            Time.timeScale = 0f;
            Node begin = Factory.CreatNode(0, new Vector2(-6.44f, 2.91f));

            begin.BecomeBegin();
            Node end = Factory.CreatNode(1, new Vector2(4.43f, 2.8f));

            end.BecomeEnd();
            Node node0 = Factory.CreatNode(2, new Vector2(-1.13f, 0.22f));
            Node node1 = Factory.CreatNode(3, new Vector2(3.83f, -3.29f));
            Node node2 = Factory.CreatNode(4, new Vector2(4, 0));

            LinkList = new List <Link>
            {
                Factory.CreatLink(begin, node0),
                Factory.CreatLink(node0, node1),
                Factory.CreatLink(node0, node2),
                Factory.CreatLink(node1, node2),
                Factory.CreatLink(node0, end)
            };

            RoutePosition r = new RoutePosition(LinkList[0], node0, 0);

            EnemiesList.Add(Factory.CreatEnemy(r));
        }
Пример #4
0
 void OnGUI()
 {
     if (debugmode)
     {
         GUI.Label(new Rect(Screen.width / 2 - 50, 45, 100, 50), "DEBUG MODE");
     }
     GUI.Label(new Rect(Screen.width - 40, Screen.height - 15, Screen.width, Screen.height), "ver.1.4");
     GUI.color = new Color(1, 1, 1, 0.8f);         //80% Opacity
     GUI.Label(new Rect(5, 5, 100, 50), "Score: " + score.ToString("000000"));
     GUI.Label(new Rect(5, 25, 100, 50), "Time: " + main.Leveltime.ToString("f1"));
     GUI.Label(new Rect(5, 45, 100, 50), "Level: " + main.Level);
     if (debugmode == true)
     {
         //FPS
         deltaTime += (Time.deltaTime - deltaTime) * 0.1f;
         float  fps     = 1.0f / deltaTime;                 //Calculates fps
         string FPStext = string.Format("{0:0.} fps", fps); // Store FPS in text string f
         GUI.Label(new Rect(Screen.width - 35, 0, Screen.width, Screen.height * 2 / 50), FPStext);
         //
     }
     if (ship == null)
     {
         GUI.Label(new Rect(Screen.width / 2 - 25, 250, 80, 30), "Game Over");
         GUI.Label(new Rect(Screen.width / 2 - 25, 300, 100, 50), "Score: " + score);
         if (GUI.Button(new Rect(Screen.width / 2 - 30, 350, 80, 30), "Retry?"))
         {
             Application.LoadLevel(0);
             EnemiesList.Clear();
             return;
         }
     }
 }    //end OnGui
Пример #5
0
    // Update is called once per frame
    void Update()
    {
        transform.Translate(Vector3.up * speed);
        if ((transform.position.y) >= ScreenHeight)
        {
            Destroy(gameObject);
        }
        //COLLISIONS
        for (int i = 0; i < Main.EnemiesList.Count; i++)
        {
            GameObject target = Main.EnemiesList[i].gameObject;
            if (target != null)                                                              // Checks to avoid missingexception
            {
                enemy = target.GetComponent <Enemies>();                                     // allows access to methods and varibles within targets constructor

                float distance = (transform.position - target.transform.position).magnitude; //creates a float which stores position between 2 variables
                //Debug.Log (target); //check the distance between two vectors
                if (distance <= 0.5f)
                {
                    enemy.SubtractLife(target);     //access enemy referance and use Subtract method to take HP away from target
                    Destroy(gameObject);            //Destroy Bullet
                }
                //Score if killed
                if (enemy.Health == 0)
                {
                    EnemyCount -= 1;                                                                      // 1 Enemy has been hit, Deduct Health
                    CreateParticles(transform.position, target.renderer.material.color, enemy.speed, 20); // Feed in particles spawn area, color and take in speed for effects
                    Destroy(target.gameObject);                                                           //Destroy Enemy
                    EnemiesList.Remove(target.gameObject);                                                //Remove enemy Gameobject from List, also avoids missingexception

                    if (target.renderer.material.color == EnemyType[0])
                    {
                        UI.ChangeScore(10);                        //Calls ChangeScore from UI Script
                    }
                    if (target.renderer.material.color == EnemyType[1])
                    {
                        UI.ChangeScore(25);
                        int spawn = Random.Range(0, 10);
                        if (spawn < 8)
                        {
                            return;
                        }
                        else
                        {
                            //BONUS PICK UP
                            GameObject bonus = GameObject.CreatePrimitive(PrimitiveType.Capsule);
                            bonus.AddComponent <Bonus>();
                            bonus.AddComponent <Strobe>();
                            bonus.transform.localScale = new Vector3(0.2f, 0.2f, 0.1f);
                            bonus.transform.position   = target.transform.position;
                        }
                    }
                    if (target.renderer.material.color == EnemyType[2])
                    {
                        UI.ChangeScore(20);
                    }
                }
            } //end target if
        }     //end For loop
    }         //end update
    }    //end FindPlayer

    // Use this for initialization
    void Start()
    {
        if (alive)
        {
            EnemiesList.Add(gameObject);
        }
        enemyCount++;
    }
Пример #7
0
 public override void Die()
 {
     if (CurrentHealth <= 0)
     {
         EnemiesList.Remove(this);
         print("[Enemy Death]: " + transform.name);
         Destroy(gameObject);
     }
 }
Пример #8
0
    private void Awake()
    {
        myGridTransform = GetComponent <GridTransform>();
        enemiesList     = GameObject.Find("Enemies").GetComponent <EnemiesList>();

        deathScreen.SetActive(false);

        healthBar.MaxHp = health;
        healthBar.Hp    = health;
    }
Пример #9
0
	public void SetEnemies(float _x, float _y, float _xScale, float _yScale, float _speed, int _health, int _level, bool _alive, int _pointvalue) {
		xPos = _x;
		yPos = _y;
		xScale = _xScale;
		yScale = _yScale;
		speed = _speed;
		Health = _health;
		Level = _level;
		alive = _alive;
		pointvalue = _pointvalue;
		//Apply Texture
//		Material mat;
//		mat = Resources.Load("Materials/EnemyShip") as Material;
//		gameObject.GetComponent<Renderer>().material=mat;
		RocketModel=Resources.Load<GameObject>("isi_textures/Enemy");//Using the inherited RocketModel variable from Ship parent class, Assign enemy ship model
		//
		if (Level <= 1 ) {
			GetComponent<Renderer>().material.color = EnemyType [0];//Spawn only reds in level 1
		}
		if (Level == 2) {
			GetComponent<Renderer>().material.color = EnemyType [Random.Range (0, 2)]; //red and green
		}
		if (Level > 2) {
			GetComponent<Renderer>().material.color = EnemyType [Random.Range (0, EnemyType.Length)];// red green and yellow
		}
		
		//ENEMY TYPES
		//Regular
		if (GetComponent<Renderer>().material.color == EnemyType [0]) {
			name="Enemy_R";//Uses default varibles supplied in Createnemy in main
			speed=0.06f;
			color=EnemyType[0];
		}
		if (GetComponent<Renderer>().material.color == EnemyType [1]) {
			name="Enemy_G";
			Health = 3;
			color=EnemyType[1];
			pointvalue=15;
			speed= Random.Range (0.08f, 0.08f);
		}
		//Lock on
		if (GetComponent<Renderer>().material.color == EnemyType [2]) {
			name="Enemy_Y";
			color=EnemyType[2];
			pointvalue=20;
			speed = Random.Range (0.12f, 0.15f);
		}
		Resetpos ();
		LoadParticles(transform.position,color, speed,5,transform);//Once everything is set, create particles for each ship
		
		Vector3 scale = new Vector3(xScale, yScale, 0.1f);
		transform.localScale = scale;
		EnemiesList.Add (gameObject);
	}
Пример #10
0
    private void DestroyEnemies()
    {
        foreach (var item in enemiesToDestroyList)
        {
            Destroy(enemyToGoMap[item]);
            enemyToGoMap.Remove(item);
            EnemiesList.Remove(item);
            EnemiesKilled++;
            pC.buildingController.AdjustGold(false, item.Bounty);
        }

        enemiesToDestroyList.Clear();
    }
    // Update is called once per frame
    void Update()
    {
        //COLLISIONS
        for (int i = 0; i < EnemiesList.Count; i++)
        {
            GameObject target = EnemiesList[i].gameObject;
            if (target != null)                                                                   // Checks to avoid missingexception
            {
                Enemies enemy       = target.GetComponent <Enemies>();                            // creates enemies instance that access referance that allows access to methods and variables within target
                Color   enemycolour = target.GetComponent <Renderer>().material.color;            // referance colour
                float   distance    = (transform.position - target.transform.position).magnitude; //creates a float which stores position between 2 variables
                //Debug.Log (target); //check the distance between two vectors
                if (distance <= 0.5f)
                {
                    enemy.SubtractLife(target);             //access enemy referance and use Subtract method to take HP away from target
                    Destroy(gameObject);                    //Destroy Bullet
                }
                //Score if killed
                if (enemy.Health == 0)
                {
                    explosionsound.Play();                                             //Play Bullet Sound clip
                    CreateParticles(transform.position, enemycolour, enemy.speed, 20); // Feed in particles spawn area, color and take in speed for effects
                    EnemiesList.Remove(target.gameObject);                             //Remove enemy Gameobject from List, also avoids missingexception

                    if (enemycolour == EnemyType[0])
                    {
                        ChangeScore(10);                        ///calls method inherited from main
                    }
                    if (enemycolour == EnemyType[1])
                    {
                        ChangeScore(25);                        //method inherited from main
                        int spawn = Random.Range(0, 10);
                        if (spawn <= 5)
                        {
                            return;
                        }
                        else
                        {
                            CreateBonus(target.transform.position);
                        }
                    }
                    if (enemycolour == EnemyType[2])
                    {
                        ChangeScore(20);                        //method inherited from main
                    }
                }
            }    //end target if
        }        //end For loop
    }
    // Update is called once per frame
    void Update()
    {
        //COLLISIONS
        for (int i = 0; i < EnemiesList.Count; i++)
        {
            GameObject target = EnemiesList[i].gameObject;
            if (target != null)
            {
                Enemies enemy = target.GetComponent <Enemies>();      // creates enemies instance that access referance that allows access to methods and variables within target
                if (target != null && enemy.alive == true)            // Checks to avoid missingexception

                //Color enemycolour=target.GetComponent<Renderer>().material.color;// referance colour
                {
                    GameObject parts    = target.transform.FindChild("p").gameObject;
                    float      distance = (transform.position - target.transform.position).magnitude;    //creates a float which stores position between 2 variables
                    //Debug.Log (target); //check the distance between two vectors
                    if (distance <= 0.5f)
                    {
                        // Enable renderer accordingly
                        enemy.SubtractLife(enemy);                //access enemy referance and use Subtract method to take HP away from target
                        gameObject.SetActive(false);              //Disable gameObject aka bullet
                    }
                    //Score if killed
                    if (enemy.Health == 0)
                    {
                        enemy.alive            = false;
                        parts.transform.parent = null;                //Breaks particles away from Enemy
                        parts.transform.parent = ParticleManager.transform;
                        parts.SetActive(true);
                        //enemy.CreateParticles(transform.position, enemycolour, enemy.speed, 20); // Feed in particles spawn area, color and take in speed for effects
                        EnemiesList.Remove(target.gameObject);                 //Remove enemy Gameobject from List, also avoids missingexception
                        if (target.GetComponent <Renderer>().material.color == EnemyType[1])
                        {
                            int spawn = Random.Range(0, 10);
                            if (spawn <= 5)
                            {
                                return;
                            }
                            else
                            {
                                CreateBonus(target.transform.position);
                            }
                        }
                    }
                } //end target if
            }
        }         //end For loop
    }
Пример #13
0
 private void StateMachineInit()
 {
     StateMachine.State = StateEnum.SettingRocket;
     StateMachine.RegisterAction(StateEnum.OnPlaying, () =>
     {
         Frame++;
         TrySetEnemyLoop();
         Time.timeScale = UIManager.CustomTimeScale;
         LoopEnemyMove();
         if (EnemiesList.IsEmpty() && EnemyWaiting.Count == 0)
         {
             StateMachine.State    = StateEnum.GameSuccess;
             UIManager.Instruction = "游戏胜利:D";
             PlaySound(_winSound);
         }
     });
 }
    void Start()
    {
        list           = GetComponent <EnemiesList>();
        enemySequences = Resources.LoadAll <GameObject>("EnemySequences");

        if (enemySequences != null && enemySequences.Length > 0)
        {
            int length = enemySequences.Length;

            RefreshNotTakenSeqs();

            needle = startPosition;
        }
        else
        {
            Destroy(this);
        }
    }
Пример #15
0
    private void SpawnEnemy(GameObject prefabToRender)
    {
        Tile spawnTile  = pC.tileController.GetSpawnTile(WaveNumber);
        Tile targetTile = pC.tileController.GetTargetTile(WaveNumber);


        GameObject enemyObj = Instantiate(
            pC.prefabController.EnemyNormalPrefab,
            new Vector3(spawnTile.X, spawnTile.Y, 0),
            Quaternion.identity,
            pC.EnemyAnchorObj.transform
            );

        _Enemy enemy = enemyObj.GetComponentInChildren <_Enemy>();

        EnemiesList.Add(enemy);
        enemyToGoMap[enemy] = enemyObj;

        enemy.Init(pC, spawnTile, targetTile);
    }
Пример #16
0
        /// <summary>
        /// 每帧运行,处理敌人的移动
        /// </summary>
        private void LoopEnemyMove()
        {
            //零、充值所有敌人的期望
            foreach (var e in EnemiesList)
            {
                e.ResetExpectation();
                //Debug.Log("Im the last, FC="+EnemiesList.Last().CrowdedFront+", BC="+EnemiesList.Last().CrowdedBack);
            }

            //一、设置所有敌人的前力后力
            foreach (var e in EnemiesList)
            {
                if ((e.CrowdedFront && (!e.CrowdedBack)) ||//这个人在末端
                    e.HasConflict //或者这个人有冲突
                    )
                {                 //对这个人,向前开始运算它们的前进后退期望(递归)
                    e.SetAllExpectation();
                }
            }

            //二、让每个敌人根据自己的情况运动,应该被删掉的敌人会把自己放到EnemiesToDelete里
            for (int i = 0; i < EnemiesList.Count; i++)
            {
                if (EnemiesList[i] == null)
                {
                    continue;
                }
                EnemiesList[i].Move();
            }

            //三、删掉刚才应该被删掉的敌人
            foreach (var e in EnemiesToDelete)
            {
                if (EnemiesList.Contains(e))
                {
                    EnemiesList.Remove(e);
                    Destroy(e.gameObject);
                }
            }
        }
Пример #17
0
 void OnGUI()
 {
     if (debugmode)
     {
         GUI.Label(new Rect(Screen.width / 2 - 50, 45, 100, 50), "DEBUG MODE");
     }
     GUI.Label(new Rect(Screen.width - 40, Screen.height - 15, Screen.width, Screen.height), "ver.1.2");
     GUI.color = new Color(1, 1, 1, 0.8f);         //80% Opacity
     GUI.Label(new Rect(5, 5, 100, 50), "Score: " + score.ToString("000000"));
     GUI.Label(new Rect(5, 25, 100, 50), "Time: " + main.Leveltime.ToString("f1"));
     GUI.Label(new Rect(5, 45, 100, 50), "Level: " + main.Level);
     if (ship == null)
     {
         GUI.Label(new Rect(Screen.width / 2 - 25, 250, 80, 30), "Game Over");
         GUI.Label(new Rect(Screen.width / 2 - 25, 300, 100, 50), "Score: " + score);
         if (GUI.Button(new Rect(Screen.width / 2 - 30, 350, 80, 30), "Retry?"))
         {
             Application.LoadLevel(0);
             EnemiesList.Clear();
             return;
         }
     }
 }    //end OnGui
Пример #18
0
        /// <summary>
        /// Update scene logics
        /// </summary>
        /// <param name="gameTime"></param>
        public override void Update(GameTime gameTime)
        {
            this.camera.Update(gameTime.ElapsedGameTime,
                         ref this.collisionMesh,
                         GamePad.GetState(PlayerIndex.One),
                         Keyboard.GetState());

            this.player.Update(gameTime, this.collisionMesh);

            GamePadState gps = GamePad.GetState(PlayerIndex.One);
            KeyboardState kbs = Keyboard.GetState();

            if (gps.Buttons.Y == ButtonState.Pressed || kbs.IsKeyDown(Keys.Enter))
            {
                if (this.player.ActualGun != null)
                {
                    Bullet b = this.player.ActualGun.Shot();

                    if (b != null)
                    {
                        Vector3 position = this.camera.GetWorldVector(3);
                        Vector3 speed = -this.camera.GetWorldVector(2) * 1000.0f;

                        b.Position = position;
                        b.Speed = speed;

                        this.bullets.Add(b);
                    }
                }
            }

            this.CheckCollisions(gameTime);

            //Manages dead enemies
            EnemiesList deadEnemies = new EnemiesList();

            foreach (KeyValuePair<String, Enemy> kvp in this.enemies)
            {
                if (kvp.Value.Dead)
                {
                    deadEnemies.Add(kvp.Key, kvp.Value);
                }
            }

            foreach (string key in deadEnemies.Keys)
            {
                this.enemies.Remove(key);
            }

            foreach (Enemy e in this.enemies.Values)
            {
                e.Update(gameTime, this.camera.world.Translation, ref this.camera.view,
                            ref this.camera.projection, ref this.collisionMesh);
            }

            ///Manages bullets
            BulletList deadBullets = new BulletList();

            foreach (Bullet b in this.bullets)
            {
                if (b.Dead)
                {
                    deadBullets.Add(b);
                }
                else
                {
                    b.Update(gameTime, this.collisionMesh);
                }
            }

            foreach (Bullet b in deadBullets)
            {
                this.bullets.Remove(b);
            }
        }
Пример #19
0
 private void Awake()
 {
     enemiesList = GameObject.FindGameObjectWithTag("GameController").GetComponent <EnemiesList> ();
     spawnPoint  = this.transform;
 }
 private void Awake()
 {
     instance = this;
 }
Пример #21
0
    // Update is called once per frame
    void Update()
    {
        transform.Translate(dir * speed);
        if ((transform.position.y) >= ScreenHeight - 2 || transform.position.y <= (-ScreenHeight / 2) - yScale * 2) //When bullets Y position is greater than ScreensHeight
        {
            gameObject.SetActive(false);                                                                            //Disable gameObject aka bullet
        }
        //COLLISIONS
        if (PlayerBullet && ship != null)
        {
            for (int i = 0; i < EnemiesList.Count; i++)
            {
                _Target = EnemiesList[i].gameObject;
                if (_Target != null)                                                                // Checks to avoid missingexception
                {
                    Enemies enemy    = _Target.GetComponent <Enemies>();                            // creates enemies instance that access referance that allows access to methods and variables within _Target
                    float   distance = (transform.position - _Target.transform.position).magnitude; //creates a float which stores position between 2 variables
                    //print(_Target); //check the distance between two vectors
                    if (distance <= 0.5f && bullet.alive)                                           // Checks to avoid missingexception
                    {
                        gameObject.SetActive(false);                                                //Disable gameObject aka bullet
                        bullet.alive = false;                                                       //Disable the bullet
                        enemy.Enemyrend.material.color = Color.red;                                 //
                        enemy.SubtractLife(_Target);                                                //access enemy referance and use Subtract method to take HP away from _Target
                    }

                    //Score if killed
                    if (enemy.Health == 0)
                    {
                        enemy.rend.material.color = enemy.color;                      //set referance back to original colour so check below for enemytype[1] works
                        Message("+" + enemy.pointvalue, enemy.transform.position);
                        ChangeScore(enemy.pointvalue);
                        enemy.alive = false;
                        enemy.Enemy.GetComponent <MeshRenderer>().enabled = false;

                        //parts.transform.parent = null;//Breaks particles away from Enemy
                        GameObject parts = _Target.transform.FindChild("p").gameObject;
                        parts.transform.parent = ParticleManager.transform;
                        parts.SetActive(true);
                        //enemy.CreateParticles(transform.position, enemycolour, enemy.speed, 20); // Feed in particles spawn area, color and take in speed for effects
                        EnemiesList.Remove(_Target.gameObject);                         //Remove enemy Gameobject from List, also avoids missingexception

                        if (enemy.rend.material.color == EnemyType[1])
                        {
                            int spawn = Random.Range(0, 100);
                            if (spawn <= 75)
                            {
                                return;
                            }
                            else
                            {
                                CreateBonus(_Target.transform.position);
                            }
                        }
                    }
                }                          //end _Target if
            }                              //end For loop
                                           //
        }
        if (!PlayerBullet && ship != null) //Enemie bullet collision
        {
            _Target = ship.gameObject;
            float distance = (_Target.transform.position - this.transform.position).magnitude;
            //print(distance);
            rend.material.SetColor("_TintColor", new Color(166f / 255f, 255f / 255f, 0f / 255f, 1)); //Greenish goo
            if (distance <= 0.55f && bullet.alive)                                                   // Checks to avoid missingexception
            {
                c = GameObject.Find("Ship/Shield");
                if (c)
                {
                    bullet.gameObject.SetActive(false);
                    bullet.alive = false;
                    killplayer(c);
                    return;
                }
                else
                {
                    bullet.gameObject.SetActive(false);
                }
                bullet.alive = false;
                killplayer(_Target);
            }
        }
        if (PlayerBullet)                                                                              //If Ship shoots the bullet
        {
            rend.material.SetColor("_TintColor", new Color(255f / 255f, 255f / 255f, 255f / 255f, 1)); // Blue
            if (mycooldown <= 5)
            {
                transform.position += transform.right * Mathf.Sin(Time.time * 10) * 0.02f;                  //Awesome sine wave
            }
        }
        //COLLISIONS
    }    //end update
Пример #22
0
 void Awake()
 {
     enemiesList = GameObject.FindGameObjectWithTag("GameController").GetComponent <EnemiesList>();
 }
Пример #23
0
        private void View_Resize(object sender, EventArgs e)
        {
            try
            {
                int width  = View.Width;
                int height = View.Height;

                Wrapper.SetControlRect(Tabs, new Rectangle(45, 50, width - 45, height - 65));

                DefinedLayout.SetControlRect(TimerList, new Rectangle(0, 0, width - 45, height - 80));
                PlayerLayout.SetControlRect(PlayerList, new Rectangle(0, 0, width - 45, (height - 65) / 2));
                PlayerLayout.SetControlRect(GuildList, new Rectangle(0, (height - 65) / 2, width - 45, (height - 65) / 2));
                LogoutLayout.SetControlRect(FriendsList, new Rectangle(0, 20, (width - 45) / 2, height - 145));
                LogoutLayout.SetControlRect(EnemiesList, new Rectangle((width - 45) / 2, 20, (width - 45) / 2, height - 145));
                CorpseLayout.SetControlRect(CorpseList, new Rectangle(0, 0, width - 45, height - 80));
                PortalLayout.SetControlRect(PortalList, new Rectangle(0, 0, width - 45, height - 80));

                PlayerList.SetColumnWidth(1, width - 215);
                PlayerList.SetColumnWidth(2, 45);
                PlayerList.SetColumnWidth(3, 75);
                PlayerList.SetColumnWidth(4, 0);

                GuildList.SetColumnWidth(1, width - 215);
                GuildList.SetColumnWidth(2, 45);
                GuildList.SetColumnWidth(3, 75);
                GuildList.SetColumnWidth(4, 0);

                TimerList.SetColumnWidth(1, width - 215);
                TimerList.SetColumnWidth(2, 45);
                TimerList.SetColumnWidth(3, 75);
                TimerList.SetColumnWidth(4, 0);

                PortalList.SetColumnWidth(1, width - 215);
                PortalList.SetColumnWidth(2, 45);
                PortalList.SetColumnWidth(3, 75);
                PortalList.SetColumnWidth(4, 0);

                CorpseList.SetColumnWidth(1, width - 215);
                CorpseList.SetColumnWidth(2, 45);
                CorpseList.SetColumnWidth(3, 75);
                CorpseList.SetColumnWidth(4, 0);

                FriendsList.SetColumnWidth(0, (width - 45) / 2 - 45);
                EnemiesList.SetColumnWidth(0, (width - 45) / 2 - 45);

                Wrapper2.SetControlRect(Tabs2, new Rectangle(45, 100, width - 45, height - 100));

                Rectangle controlRect = Wrapper.GetControlRect(VersusNote);
                Wrapper.SetControlRect(VersusNote, new Rectangle(width - 125, 32, 35, 15));
                controlRect = Wrapper.GetControlRect(GuildNote);
                Wrapper.SetControlRect(GuildNote, new Rectangle(width - 205, 32, 70, 15));
                controlRect = Wrapper.GetControlRect(EnemyNote);
                Wrapper.SetControlRect(EnemyNote, new Rectangle(width - 75, 32, 70, 15));

                controlRect = LogoutLayout.GetControlRect(AddFriend);
                LogoutLayout.SetControlRect(AddFriend, new Rectangle((width - 45) / 2 - 40, height - 125, 40, 15));
                controlRect = LogoutLayout.GetControlRect(AddEnemy);
                LogoutLayout.SetControlRect(AddEnemy, new Rectangle(width - 85, height - 125, 40, 15));
                controlRect = LogoutLayout.GetControlRect(Friend);
                LogoutLayout.SetControlRect(Friend, new Rectangle(4, height - 125, (width - 45) / 2 - 45, 15));
                controlRect = LogoutLayout.GetControlRect(Enemy);
                LogoutLayout.SetControlRect(Enemy, new Rectangle((width - 45) / 2 + 5, height - 125, (width - 45) / 2 - 45, 15));

                controlRect = LogoutLayout.GetControlRect(FriendsNote);
                LogoutLayout.SetControlRect(FriendsNote, new Rectangle(5, 0, (width / 2) - 5, 15));
                controlRect = LogoutLayout.GetControlRect(EnemiesNote);
                LogoutLayout.SetControlRect(EnemiesNote, new Rectangle((width / 2) + 5, 0, (width / 2) - 5, 15));

                controlRect = AlertLayout.GetControlRect(AudioNote);
                AlertLayout.SetControlRect(AudioNote, new Rectangle(5, 5, width - 10, 20));
                controlRect = AlertLayout.GetControlRect(AlertSPK);
                AlertLayout.SetControlRect(AlertSPK, new Rectangle(5, 25, ((width - 45) / 2) - 10, 20));
                controlRect = AlertLayout.GetControlRect(AlertSS);
                AlertLayout.SetControlRect(AlertSS, new Rectangle(((width - 45) / 2) + 10, 25, (width / 2) - 10, 20));
                controlRect = AlertLayout.GetControlRect(AlertOdds);
                AlertLayout.SetControlRect(AlertOdds, new Rectangle(5, 45, ((width - 45) / 2) - 10, 20));
                controlRect = AlertLayout.GetControlRect(AlertBc);
                AlertLayout.SetControlRect(AlertBc, new Rectangle(((width - 45) / 2) + 10, 45, (width / 2) - 10, 20));
                controlRect = AlertLayout.GetControlRect(AlertDT);
                AlertLayout.SetControlRect(AlertDT, new Rectangle(5, 65, ((width - 45) / 2) - 10, 20));
                controlRect = AlertLayout.GetControlRect(AlertPKT);
                AlertLayout.SetControlRect(AlertPKT, new Rectangle(((width - 45) / 2) + 10, 65, (width / 2) - 10, 20));

                controlRect = AlertLayout.GetControlRect(TextNote);
                AlertLayout.SetControlRect(TextNote, new Rectangle(5, 85, width - 10, 20));
                controlRect = AlertLayout.GetControlRect(AlertPA);
                AlertLayout.SetControlRect(AlertPA, new Rectangle(5, 105, ((width - 45) / 2) - 10, 20));
                controlRect = AlertLayout.GetControlRect(AlertPF);
                AlertLayout.SetControlRect(AlertPF, new Rectangle(5, 125, ((width - 45) / 2) - 10, 20));
                controlRect = AlertLayout.GetControlRect(AlertLogP);
                AlertLayout.SetControlRect(AlertLogP, new Rectangle(((width - 45) / 2) + 10, 105, ((width - 45) / 2) - 10, controlRect.Height));
                controlRect = AlertLayout.GetControlRect(AlertDA);
                AlertLayout.SetControlRect(AlertDA, new Rectangle(((width - 45) / 2) + 10, 125, ((width - 45) / 2) - 10, controlRect.Height));
                controlRect = AlertLayout.GetControlRect(AlertLS);
                AlertLayout.SetControlRect(AlertLS, new Rectangle(5, 145, ((width - 45) / 2) - 10, 20));

                controlRect = AlertLayout.GetControlRect(SaveSettings2);
                AlertLayout.SetControlRect(SaveSettings2, new Rectangle(0, height - 107, width - 45 - 60, 15));
                controlRect = AlertLayout.GetControlRect(ResetAlarms);
                AlertLayout.SetControlRect(ResetAlarms, new Rectangle(width - 45 - 60, height - 107, 60, 15));

                controlRect = SentryLayout.GetControlRect(ElementLbl);
                SentryLayout.SetControlRect(ElementLbl, new Rectangle(5, 5, 60, 20));
                controlRect = SentryLayout.GetControlRect(BehaviourLbl);
                SentryLayout.SetControlRect(BehaviourLbl, new Rectangle((width - 45) / 2 + 5, 5, 60, 20));

                controlRect = SentryLayout.GetControlRect(Element);
                SentryLayout.SetControlRect(Element, new Rectangle(5, 25, (width - 45) / 2 - 10, 20));
                controlRect = SentryLayout.GetControlRect(Behaviour);
                SentryLayout.SetControlRect(Behaviour, new Rectangle((width - 45) / 2 + 5, 25, (width - 45) / 2 - 10, 20));

                controlRect = SentryLayout.GetControlRect(Ticker);
                SentryLayout.SetControlRect(Ticker, new Rectangle(5, 45, 60, 15));
                controlRect = SentryLayout.GetControlRect(TickerNote);
                SentryLayout.SetControlRect(TickerNote, new Rectangle(70, 45, (width - 45) / 2 - 45, 15));
                controlRect = SentryLayout.GetControlRect(TickerNote2);
                SentryLayout.SetControlRect(TickerNote2, new Rectangle(5, 60, width - 45, 15));

                controlRect = SentryLayout.GetControlRect(Range);
                SentryLayout.SetControlRect(Range, new Rectangle(5, 85, 30, 15));
                controlRect = SentryLayout.GetControlRect(RangeNote);
                SentryLayout.SetControlRect(RangeNote, new Rectangle(40, 85, 120, 15));

                controlRect = SentryLayout.GetControlRect(Timer);
                SentryLayout.SetControlRect(Timer, new Rectangle(5, 105, 30, 15));
                controlRect = SentryLayout.GetControlRect(TimerNote);
                SentryLayout.SetControlRect(TimerNote, new Rectangle(40, 105, 120, 15));

                controlRect = SentryLayout.GetControlRect(Comps);
                SentryLayout.SetControlRect(Comps, new Rectangle(5, 125, 30, 15));
                controlRect = SentryLayout.GetControlRect(TapersNote);
                SentryLayout.SetControlRect(TapersNote, new Rectangle(40, 125, 120, 15));

                controlRect = SentryLayout.GetControlRect(Slots);
                SentryLayout.SetControlRect(Slots, new Rectangle(5, 145, 30, 15));
                controlRect = SentryLayout.GetControlRect(SlotsNote);
                SentryLayout.SetControlRect(SlotsNote, new Rectangle(40, 145, 120, 15));



                controlRect = SentryLayout.GetControlRect(UseMacroLogic);
                SentryLayout.SetControlRect(UseMacroLogic, new Rectangle((width - 45) / 2 + 5, 85, (width - 45) / 2 - 10, 15));
                controlRect = SentryLayout.GetControlRect(UseLogDie);
                SentryLayout.SetControlRect(UseLogDie, new Rectangle((width - 45) / 2 + 5, 105, (width - 45) / 2 - 10, 15));

                controlRect = SentryLayout.GetControlRect(SaveSettings3);
                SentryLayout.SetControlRect(SaveSettings3, new Rectangle(0, height - 107, width - 45 - 60, 15));
                controlRect = SentryLayout.GetControlRect(ResetOptions);
                SentryLayout.SetControlRect(ResetOptions, new Rectangle(width - 45 - 60, height - 107, 60, 15));

                controlRect = Wrapper.GetControlRect(Die);
                Wrapper.SetControlRect(Die, new Rectangle(0, height - 15, 40, 15));
                controlRect = Wrapper.GetControlRect(IgnoreVP);
                Wrapper.SetControlRect(IgnoreVP, new Rectangle(40, height - 15, 40, 15));
                controlRect = Wrapper.GetControlRect(Fixbusy);
                Wrapper.SetControlRect(Fixbusy, new Rectangle(80, height - 15, 40, 15));
                controlRect = Wrapper.GetControlRect(Loc);
                Wrapper.SetControlRect(Loc, new Rectangle(120, height - 15, 40, 15));

                controlRect = Wrapper.GetControlRect(ModeLbl);
                Wrapper.SetControlRect(ModeLbl, new Rectangle(165, height - 15, 35, 15));
                controlRect = Wrapper.GetControlRect(Mode);
                Wrapper.SetControlRect(Mode, new Rectangle(200, height - 15, width - 190, 15));

                controlRect = Wrapper.GetControlRect(Imperil);
                Wrapper.SetControlRect(Imperil, new Rectangle(0, 0, 40, 15));
                controlRect = Wrapper.GetControlRect(Bludge);
                Wrapper.SetControlRect(Bludge, new Rectangle(40, 0, 40, 15));
                controlRect = Wrapper.GetControlRect(Slash);
                Wrapper.SetControlRect(Slash, new Rectangle(80, 0, 40, 15));
                controlRect = Wrapper.GetControlRect(Pierce);
                Wrapper.SetControlRect(Pierce, new Rectangle(120, 0, 40, 15));
                controlRect = Wrapper.GetControlRect(Light);
                Wrapper.SetControlRect(Light, new Rectangle(0, 15, 40, 15));
                controlRect = Wrapper.GetControlRect(Acid);
                Wrapper.SetControlRect(Acid, new Rectangle(40, 15, 40, 15));
                controlRect = Wrapper.GetControlRect(Fire);
                Wrapper.SetControlRect(Fire, new Rectangle(80, 15, 40, 15));
                controlRect = Wrapper.GetControlRect(Cold);
                Wrapper.SetControlRect(Cold, new Rectangle(120, 15, 40, 15));

                controlRect = Wrapper.GetControlRect(Stam);
                Wrapper.SetControlRect(Stam, new Rectangle(200, 0, 40, 15));
                controlRect = Wrapper.GetControlRect(Harm);
                Wrapper.SetControlRect(Harm, new Rectangle(200, 15, 40, 15));
                controlRect = Wrapper.GetControlRect(Tag);
                Wrapper.SetControlRect(Tag, new Rectangle(240, 0, width - 240, 30));

                controlRect = AdminLayout.GetControlRect(AdminNote);
                AdminLayout.SetControlRect(AdminNote, new Rectangle(5, 5, width - 50, 15));
                controlRect = AdminLayout.GetControlRect(ForcelogNote);
                AdminLayout.SetControlRect(ForcelogNote, new Rectangle(5, 35, 100, 15));
                controlRect = AdminLayout.GetControlRect(ForcelogBox);
                AdminLayout.SetControlRect(ForcelogBox, new Rectangle(5, 55, width - 110, 15));
                controlRect = AdminLayout.GetControlRect(ForcelogButton);
                AdminLayout.SetControlRect(ForcelogButton, new Rectangle(0, 85, (width - 50) / 2, 15));
                controlRect = AdminLayout.GetControlRect(ForceRelogButton);
                AdminLayout.SetControlRect(ForceRelogButton, new Rectangle((width - 50) / 2, 85, (width - 50) / 2, 15));

                controlRect = AdminLayout.GetControlRect(ForcelocButton);
                AdminLayout.SetControlRect(ForcelocButton, new Rectangle(0, 105, (width - 50) / 2, 15));
                controlRect = AdminLayout.GetControlRect(ForcedieButton);
                AdminLayout.SetControlRect(ForcedieButton, new Rectangle((width - 50) / 2, 105, (width - 50) / 2, 15));

                controlRect = Wrapper.GetControlRect(Strength);
                Wrapper.SetControlRect(Strength, new Rectangle(0, 50, 20, 20));
                controlRect = Wrapper.GetControlRect(Endurance);
                Wrapper.SetControlRect(Endurance, new Rectangle(20, 50, 20, 20));
                controlRect = Wrapper.GetControlRect(Coordination);
                Wrapper.SetControlRect(Coordination, new Rectangle(0, 70, 20, 20));
                controlRect = Wrapper.GetControlRect(Quickness);
                Wrapper.SetControlRect(Quickness, new Rectangle(20, 70, 20, 20));
                controlRect = Wrapper.GetControlRect(Focus);
                Wrapper.SetControlRect(Focus, new Rectangle(0, 90, 20, 20));
                controlRect = Wrapper.GetControlRect(Willpower);
                Wrapper.SetControlRect(Willpower, new Rectangle(20, 90, 20, 20));

                controlRect = Wrapper.GetControlRect(Run);
                Wrapper.SetControlRect(Run, new Rectangle(0, 120, 20, 20));
                controlRect = Wrapper.GetControlRect(StamRegen);
                Wrapper.SetControlRect(StamRegen, new Rectangle(20, 120, 20, 20));

                controlRect = Wrapper.GetControlRect(Creature);
                Wrapper.SetControlRect(Creature, new Rectangle(0, 150, 20, 20));
                controlRect = Wrapper.GetControlRect(Life);
                Wrapper.SetControlRect(Life, new Rectangle(20, 150, 20, 20));
                controlRect = Wrapper.GetControlRect(War);
                Wrapper.SetControlRect(War, new Rectangle(0, 170, 20, 20));
                controlRect = Wrapper.GetControlRect(MagicD);
                Wrapper.SetControlRect(MagicD, new Rectangle(20, 170, 20, 20));
                controlRect = Wrapper.GetControlRect(HeavyW);
                Wrapper.SetControlRect(HeavyW, new Rectangle(0, 190, 20, 20));
                controlRect = Wrapper.GetControlRect(MelD);
                Wrapper.SetControlRect(MelD, new Rectangle(20, 190, 20, 20));
                controlRect = Wrapper.GetControlRect(MissW);
                Wrapper.SetControlRect(MissW, new Rectangle(0, 210, 20, 20));
                controlRect = Wrapper.GetControlRect(MissD);
                Wrapper.SetControlRect(MissD, new Rectangle(20, 210, 20, 20));
            }
            catch (Exception ex) { Repo.RecordException(ex); }
        }
        /// <summary>
        /// Get enemies attributes
        /// </summary>
        /// <param name="xmlDoc">XML doc with attributes</param>
        /// <param name="enemies">enemies list</param>
        public static void LoadEnemiesAttributes(Game game, XmlDocument xmlDoc, ref EnemiesList enemies)
        {
            Debug.Assert(xmlDoc != null);
            Debug.Assert(enemies != null);
            Debug.Assert(game != null);

            XmlNodeList nodeList = xmlDoc.GetElementsByTagName("enemies");

            if (nodeList.Count > 0) //if XML has ammopacks...
            {
                //get list of guns in scene
                XmlElement nodeElement = (XmlElement)nodeList.Item(0);

                //get all guns definitions from XML file
                foreach (XmlElement xmle in nodeElement.ChildNodes)
                {
                    String assetName = null;
                    String[] statesNames = new String[5];
                    Enemy e = new Enemy();

                    try
                    {
                        String modelName = Convert.ToString(xmle.GetAttribute("assetName"));
                        Model m = SystemResources.Content.Load<Model>(@modelName);

                        assetName = Convert.ToString(xmle.GetAttribute("name"));
                        e.ModelAnimator = new ModelAnimator(game, m);
                        e.ScaleFactor = Convert.ToSingle(xmle.GetAttribute("scaleFactor"));
                        e.RunSpeed = Convert.ToSingle(xmle.GetAttribute("runSpeed"));
                        e.WalkSpeed = Convert.ToSingle(xmle.GetAttribute("walkSpeed"));
                        e.Health = Convert.ToInt32(xmle.GetAttribute("health"));
                        int seconds = Convert.ToInt32(xmle.GetAttribute("dieTime"));
                        e.TotalDieTime = new TimeSpan(0, 0, seconds);

                        game.Components.Remove(e.ModelAnimator); //We manage update and call

                        statesNames[0] = Convert.ToString(xmle.GetAttribute("idleState"));
                        statesNames[1] = Convert.ToString(xmle.GetAttribute("walkState"));
                        statesNames[2] = Convert.ToString(xmle.GetAttribute("runState"));
                        statesNames[3] = Convert.ToString(xmle.GetAttribute("attackState"));
                        statesNames[4] = Convert.ToString(xmle.GetAttribute("dieState"));

                        e.IdleController = new AnimationController(game, e.ModelAnimator.Animations[statesNames[0]]);
                        e.WalkController = new AnimationController(game, e.ModelAnimator.Animations[statesNames[1]]);
                        e.RunController = new AnimationController(game, e.ModelAnimator.Animations[statesNames[2]]);
                        e.AttackController = new AnimationController(game, e.ModelAnimator.Animations[statesNames[3]]);
                        e.DieController = new AnimationController(game, e.ModelAnimator.Animations[statesNames[4]]);
                    }
                    catch (InvalidCastException ice)
                    {
                        Log.Write("BuildObjectsList: InvalidCastExpcetion raised (did you forget some enemy setting?)");
                        Log.Write(ice.Message);
                    }

                    enemies.Add(assetName, e);
                }
            }
        }