コード例 #1
0
ファイル: SwordDamage.cs プロジェクト: FerranPF/Celestus
    public void MyCollision()
    {
        Collider[] enemyColliders = Physics.OverlapBox(transform.position, transform.localScale, Quaternion.LookRotation(Vector3.forward, Vector3.up));
        int        i = 0;

        //Check when there is a new collider coming into contact with the box
        while (i < enemyColliders.Length)
        {
            //Damage every enemy in the collider
            Debug.Log("Hit : " + enemyColliders[i].name + i);
            if (enemyColliders[i].tag == "Enemy")
            {
                EnemyController enemy = enemyColliders[i].GetComponent <EnemyController>();
                enemy.GetDamage(Random.Range(damage - difDamage, damage + difDamage));
            }
            if (enemyColliders[i].tag == "Turret")
            {
                TurretEnemy turret = enemyColliders[i].GetComponent <TurretEnemy>();
                turret.TakeDamage(Random.Range(damage - difDamage, damage + difDamage));
            }
            if (enemyColliders[i].tag == "Father")
            {
                BossController father = enemyColliders[i].GetComponent <BossController>();
                father.GetDamage(Random.Range(damage - difDamage, damage + difDamage));
            }
            //Increase the number of Colliders in the array
            i++;
        }
    }
コード例 #2
0
ファイル: Room.cs プロジェクト: trimute2/DIEPARTISAN
        /// <summary>
        /// Takes a Room and creates everything that is not a floor tile
        /// </summary>
        /// <param name="enemyTexture">Texture of enemies in this room</param>
        /// <param name="wallTexture">Texture of walls in this room</param>
        public void initRoom(Texture2D wallTextures, Texture2D floorTextures, Graph.Graph graph)
        {
            //Init room's textures
            this.wallTextures  = wallTextures;
            this.floorTextures = floorTextures;

            //Should change this later
            int tileSize          = 64;
            int roomSize          = 10;
            int enemySpriteWidth  = 39;
            int enemySpriteHeight = 38;
            Pod pod = new Pod();

            for (int i = 0; i < roomSize; i++)
            {
                for (int j = 0; j < roomSize; j++)
                {
                    Vector2 currPos =
                        new Vector2(
                            position.X + tileSize * i,
                            position.Y + tileSize * j);
                    Vector2 midPos =
                        new Vector2(
                            currPos.X + (tileSize / 4),
                            currPos.Y + (tileSize / 4));
                    switch (tileLayout[i, j])
                    {
                    //Create walls
                    case TileType.WALL:
                        ChunkManager.Instance.Add(
                            new Wall(
                                floorTextures,
                                currPos,
                                new Rectangle(
                                    (int)currPos.X,
                                    (int)currPos.Y,
                                    tileSize,
                                    tileSize)));
                        break;

                    //Move player
                    case TileType.PLAYER:
                        Player.Instance.Position = currPos;
                        Player.Instance.ResetPlayerNewMap();
                        Player.Instance.CurrWeapon.ResetWeapon();

                        Weapons.Weapon temp = Player.Instance.CurrWeapon;
                        temp.X = currPos.X + Player.Instance.BoundingBox.Width / 2;
                        temp.Y = currPos.Y + Player.Instance.BoundingBox.Height / 2;
                        Camera.Instance.resetPosition(Player.Instance.Position);

                        //Add this position to the graph
                        graph.Add(new Graph.GraphNode(midPos));
                        spawnroom = true;
                        break;

                    //Create Melee Enemies
                    case TileType.MELEEENEMY:

                        graph.Add(new Graph.GraphNode(midPos));

                        //Create new enemy
                        MeleeEnemy newEnemy =
                            new MeleeEnemy(
                                TextureManager.Instance.GetEnemyTexture("EnemyTexture"),
                                midPos,
                                new Rectangle(
                                    (int)midPos.X,
                                    (int)midPos.Y,
                                    enemySpriteWidth,
                                    enemySpriteHeight));

                        //Add Enemy to game
                        EntityManager.Instance.Add(newEnemy);
                        ChunkManager.Instance.Add(newEnemy);
                        pod.Add(newEnemy);
                        break;

                    //Create Turret Enemies
                    case TileType.TURRET:
                        //Create new enemy
                        TurretEnemy turret =
                            new TurretEnemy(
                                TextureManager.Instance.GetEnemyTexture("EnemyTexture"),
                                midPos,
                                new Rectangle(
                                    (int)midPos.X,
                                    (int)midPos.Y,
                                    enemySpriteWidth,
                                    enemySpriteHeight));

                        //Add Enemy to game
                        EntityManager.Instance.Add(turret);
                        ChunkManager.Instance.Add(turret);
                        pod.Add(turret);
                        break;

                    case TileType.DASHENEMY:
                        graph.Add(new Graph.GraphNode(midPos));

                        //Create new enemy
                        DashEnemy dash =
                            new DashEnemy(
                                TextureManager.Instance.GetEnemyTexture("EnemyTexture"),
                                midPos,
                                new Rectangle(
                                    (int)midPos.X,
                                    (int)midPos.Y,
                                    enemySpriteWidth,
                                    enemySpriteHeight));

                        //Add Enemy to game
                        EntityManager.Instance.Add(dash);
                        ChunkManager.Instance.Add(dash);
                        pod.Add(dash);
                        break;

                    default:
                        //Add this position to the graph
                        graph.Add(new Graph.GraphNode(midPos));
                        break;
                    }
                }
            }
            PodManager.Instance.Add(pod);

            InitTextureMap();
        }
コード例 #3
0
 // Use this for initialization
 void Start()
 {
     cooldown = 0;
     turret   = GetComponent <TurretEnemy>();
 }