示例#1
0
    private void OnDestroy()
    {
        ShootingEnemy newEnemy = Instantiate <ShootingEnemy>(prefab, player.transform.position + player.transform.right * retreatDistance, transform.rotation);

        newEnemy.player = player;
        newEnemy.prefab = prefab;
    }
示例#2
0
        override protected void spawn()
        {
            ShootingEnemy.createRandomEnemy(m_sizeMin, m_sizeMax, m_speedMin, m_speedMax, m_rotationSpeedMin, m_rotationSpeedMax, m_cooldownMin, m_cooldownMax, m_projectileSizeMin, m_projectileSizeMax, m_projecdtileSpeedMin, m_projecdtileSpeedMax);
            if (m_spawnInterval > 2f)
            {
                m_spawnInterval *= 0.9f;
            }

            if (m_speedMax < 30.0f)
            {
                m_speedMin *= 1.15f;
                m_speedMax *= 1.15f;
            }

            if (m_cooldownMax > 0.5f)
            {
                m_cooldownMin *= 0.85f;
                m_cooldownMax *= 0.85f;
            }

            if (m_projectileSizeMax < 7.5f)
            {
                m_projectileSizeMin *= 1.1f;
                m_projectileSizeMax *= 1.15f;
            }

            if (m_projecdtileSpeedMax < 150f)
            {
                m_projecdtileSpeedMin *= 1.15f;
                m_projecdtileSpeedMax *= 1.15f;
            }
        }
示例#3
0
 // Start is called before the first frame update
 void Start()
 {
     player           = GameObject.Find("MonkE").transform;
     target           = new Vector2(player.position.x, player.position.y);
     enemy            = GameObject.Find("shooting enemy (Clone)").GetComponent <ShootingEnemy>();
     playerController = GameObject.Find("MonkE").GetComponent <PlayerController>();
 }
示例#4
0
    //Bıçaklı askerin sprite rendererı



    void Start()
    {
        code = GameObject.FindGameObjectWithTag("RifleSoldier");
        //RifleSoldier etiketli oyun objesini kod ile eşleştirmek
        Sh = code.GetComponent <Shooting>();

        moveCode = GameObject.FindGameObjectWithTag("RifleSoldier");

        pm    = moveCode.GetComponent <PlayerMovement_>();
        Enemy = GameObject.FindGameObjectWithTag("Teror");
        Se    = Enemy.GetComponent <ShootingEnemy>();



        //Shooting scriptimizdeki kodu eşleştiriyoruz
        rifle_sol = GameObject.FindGameObjectWithTag("RifleSoldier");
        //RifleSoldier etiketli oyun objesini rile_sol'a atıyourz
        knife_sol_render = GameObject.FindGameObjectWithTag("KnifeSoldier");
        //Tagi knife soldier olan nesnenin özelliklerini atadık
        // knife_sol_sr = knife_sol_render.GetComponent<SpriteRenderer>();
        //Bos bir rendera knife soldierın renderinin özelliklerini atadık
        //atamaları yapıyoruz amk biliyoruz zaten uğraştırıyorsunuz
        knife_pc_ob = GameObject.FindGameObjectWithTag("KnifeSoldier");
        // knife_pc = knife_pc_ob.GetComponent<PolygonCollider2D>();
    }
示例#5
0
    private void OnTriggerEnter2D(Collider2D hitInfo)
    {
        Debug.Log(hitInfo.name);
        Enemy         enemy         = hitInfo.GetComponent <Enemy>();
        ShootingEnemy shootingEnemy = hitInfo.GetComponent <ShootingEnemy>();

        if (enemy != null)
        {
            FindObjectOfType <AudioManager>().Play("fireball_impact_ground");
            enemy.TakeDamege(damage);
            Instantiate(spellEnemyImpact, transform.position, transform.rotation);
            Destroy(gameObject);
        }
        else if (shootingEnemy != null)
        {
            FindObjectOfType <AudioManager>().Play("fireball_impact_ground");
            shootingEnemy.TakeDamege(damage);
            Instantiate(spellEnemyImpact, transform.position, transform.rotation);
            Destroy(gameObject);
        }
        else
        {
            FindObjectOfType <AudioManager>().Play("fireball_impact_ground");
            Instantiate(spellGroundInpact, transform.position, transform.rotation);
            Destroy(gameObject);
        }
    }
 void Start()
 {
     Player = GameObject.FindGameObjectWithTag("RifleSoldier");
     Pm     = Player.GetComponent <PlayerMovement_>();
     Enemy  = GameObject.FindGameObjectWithTag("Teror");
     Se     = Enemy.GetComponent <ShootingEnemy>();
     MedKit = GameObject.FindGameObjectWithTag("Med");
     Mk     = MedKit.GetComponent <MedKit>();
 }
示例#7
0
 // Start is called before the first frame update
 void Start()
 {
     ctrl_boss          = FindObjectOfType <BossScript>();
     ctrl_Player        = FindObjectOfType <CharacterController2D>();
     ctrl_enemy         = FindObjectOfType <EnemyMelee>();
     ctrl_ShootingEnemy = FindObjectOfType <ShootingEnemy>();
     ctrl_flierEnemy    = FindObjectOfType <FlierEnemy>();
     spriteRenderer     = GetComponent <SpriteRenderer>();
 }
示例#8
0
    private void OnTriggerEnter2D(Collider2D hitInfo)
    {
        Debug.Log(hitInfo.name);
        Enemy         enemy         = hitInfo.GetComponent <Enemy>();
        ShootingEnemy shootingEnemy = hitInfo.GetComponent <ShootingEnemy>();

        if (enemy != null)
        {
            enemy.TakeDamege(damage);
        }
        else if (shootingEnemy != null)
        {
            shootingEnemy.TakeDamege(damage);
        }
    }
示例#9
0
 public void SpawnEntities()
 {
     GetBrains();
     foreach (KeyValuePair <Phenotype, double> kv in brains)
     {
         Random rand = new Random();
         // Simple_Ai new_spawn = mob.Instance() as Simple_Ai;
         ShootingEnemy new_spawn = mob.Instance() as ShootingEnemy;
         new_spawn.Death          += this.DeathEvent;
         new_spawn.Position        = new Vector2(rand.Next(10, 2000), rand.Next(10, 2000));
         new_spawn.RotationDegrees = rand.Next(0, 360);
         // new_spawn.Position = new Vector2(0, 0);
         // new_spawn.AddBrain(kv.Key, this.target);
         new_spawn.AddBrain(kv.Key);
         target.AddChild(new_spawn);
     }
 }
示例#10
0
        public void addEnemy()
        {
            EnemyBase enemy;

            switch (randInt(1, 5))
            {
            case 4:
                enemy = new RunningEnemy(new Vector2(randInt(0, mapManager.getMapWidth() - 200), -500));
                break;

            default:
                enemy = new ShootingEnemy(new Vector2(randInt(0, mapManager.getMapWidth() - 200), -500));
                break;
            }
            enemy.Load(EnemyTextures.idle, enemyAnimations);
            enemiesList.Add(enemy);
        }
示例#11
0
    public float numberDistanceForMelee = 1; //расстояние для милишной атаки


    void Start()
    {
        AImanager.AIlist.Add(this);//this или getComponnent? передаём ссылку на экземпляр в менеджер
        gameObject.name = "Monster " + Random.Range(0, 100);



        _rigidbody      = GetComponent <Rigidbody2D>();
        _rigidbody.mass = mass;

        MOVE  = GetComponent <MoveEnemy>();
        SHOOT = GetComponent <ShootingEnemy>();
        MELEE = GetComponent <MeleeEnemy>();
        DEATH = GetComponent <Death>();
        //player = GameObject.Find("Player");
        //_animation = GetComponent<Animator>();
        //body = GetComponent<Rigidbody2D>();
    }
示例#12
0
文件: test2.cs 项目: Uggeli/GodotNeat
    public void getBest()
    {
        double        bestScore = double.MinValue;
        ShootingEnemy bestAgent = null;

        foreach (ShootingEnemy agent in SpawnContainer.GetChildren())
        {
            if (agent.Score > bestScore)
            {
                bestAgent = agent;
                bestScore = agent.Score;
            }
        }
        camera.Position = bestAgent.GlobalPosition;
        label.Text      = $"Generation:{Generation}\nBest Agent Network:";
        best            = bestAgent.GetPhenotype();
        best_set        = true;
        // VisualiseNetwork(bestAgent.GetPhenotype());
    }
示例#13
0
    /*void Explode()
     * {
     *  Collider[] colliders = Physics.OverlapSphere(transform.position, explosionRadius);
     *  foreach (Collider collider in colliders)
     *  {
     *      if (collider.tag == "Enemy")
     *      {
     *          Damage(collider.transform);
     *      }
     *  }
     * }*/

    void Damage(Transform target)
    {
        Enemy         e    = target.GetComponent <Enemy>();
        Turret        t    = target.GetComponent <Turret>();
        ShootingEnemy eAtt = target.GetComponent <ShootingEnemy>();

        if (e != null)
        {
            e.TakeDamage(damage);
        }
        if (t != null)
        {
            t.TakeDamage(damage);
        }
        if (eAtt != null)
        {
            eAtt.TakeDamage(damage);
        }
    }
示例#14
0
 protected override void OnCollisionEnter2D(Collision2D collision)
 {
     if (collision.transform.GetComponent <BaseEnemy>())
     {
         BaseEnemy b = collision.transform.GetComponent <BaseEnemy>();
         b.health -= damage;
         Destroy(gameObject);
     }
     if (collision.transform.GetComponent <PlayerTargetingEnemy>())
     {
         PlayerTargetingEnemy tg = collision.transform.GetComponent <PlayerTargetingEnemy>();
         tg.health -= damage;
         Destroy(gameObject);
     }
     if (collision.transform.GetComponent <ShootingEnemy>())
     {
         ShootingEnemy se = collision.transform.GetComponent <ShootingEnemy>();
         se.health -= damage;
         Destroy(gameObject);
     }
     if (collision.transform.GetComponent <BossEnemy>())
     {
         BossEnemy be = collision.transform.GetComponent <BossEnemy>();
         be.health -= damage;
         Destroy(gameObject);
     }
     if (collision.transform.GetComponent <EnemyBullet>())
     {
         EnemyBullet eb = collision.transform.GetComponent <EnemyBullet>();
         Destroy(gameObject);
     }
     if (collision.transform.GetComponent <Wall>())
     {
         Destroy(gameObject);
     }
     else if (collision.transform.GetComponent <RepairBullet>())
     {
         Destroy(gameObject);
     }
     base.OnCollisionEnter2D(collision);
 }
示例#15
0
    public static DefaultEnemy createRandomEnemy(float sizeMin           = 3f, float sizeMax = 5f, float speedMin = 2f, float speedMax = 20f, float rotationSpeedMin = -1.3f, float rotationSpeedMax = 1.3f, float minCooldown = 0.5f, float maxCooldown = 1.0f,
                                                 float minProjectileSize = 1.0f, float maxProjectileSize = 1.5f, float minProjectileSpeed = 25f, float maxProjectileSpeed = 50f, int minProjectileDamage = 1, int maxProjectileDamage = 1)
    {
        float widthHeight = Random.Range(sizeMin, sizeMax);

        if (!findNewFreePosition(widthHeight, widthHeight, out Vector2 position))
        {
            return(null);
        }

        float speed   = Random.Range(speedMin, speedMax);
        float targetX = Random.Range(-10f, 10f);
        float targetY = Random.Range(-10f, 10f);

        float rotationSpeed = Random.Range(rotationSpeedMin, rotationSpeedMax);

        if (rotationSpeed < 0.05f && rotationSpeed > -0.05f)
        {
            if (rotationSpeed > 0)
            {
                rotationSpeed += 0.1f;
            }
            else
            {
                rotationSpeed -= 0.1f;
            }
        }
        float startDegrees = Random.Range(0.0f, 360.0f);

        ShootingEnemy enemy = (ShootingEnemy)createNewEnemy(position.x, position.y, widthHeight, widthHeight, targetX, targetY, speed, rotationSpeed, startDegrees, "Prefabs/Enemies/ShootingEnemy");

        enemy.m_cooldown         = Random.Range(minCooldown, maxCooldown);
        enemy.m_projectileSize   = Random.Range(minProjectileSize, maxProjectileSize);
        enemy.m_projectileSpeed  = Random.Range(minProjectileSpeed, maxProjectileSpeed);
        enemy.m_projectileDamage = Random.Range(minProjectileDamage, maxProjectileDamage);
        return(enemy);
    }
示例#16
0
 private void Start()
 {
     Tf = GameObject.FindGameObjectWithTag("Teror");
     Em = Tf.GetComponent <ShootingEnemy>();
 }
示例#17
0
        public static void loadContentEnemies(ref int enemiesAmount, BaseEnemy[] enemies, ContentManager Content, int currentLevel, GameMode gameMode)
        {
            if (gameMode == GameMode.SurvivalMode)
            {
                enemiesAmount = GameConstants.SurvivalModeMaxShootingEnemy + GameConstants.SurvivalModeMaxCombatEnemy + GameConstants.SurvivalModeMaxGhostPirate
                + GameConstants.SurvivalModeMaxMutantShark + GameConstants.SurvivalModeMaxTerminator + GameConstants.SurvivalModeMaxSubmarine;
            }
            else if (gameMode == GameMode.MainGame)
                enemiesAmount = GameConstants.NumberShootingEnemies[currentLevel] + GameConstants.NumberCombatEnemies[currentLevel] + GameConstants.NumberGhostPirate[currentLevel]
                    + GameConstants.NumberMutantShark[currentLevel] + GameConstants.NumberTerminator[currentLevel] + GameConstants.NumberSubmarine[currentLevel];
            else if (gameMode == GameMode.ShipWreck)
            {
                enemiesAmount = GameConstants.ShipNumberGhostPirate[PlayGameScene.currentLevel];
            }
            int numShootingEnemies = 0;
            int numCombatEnemies = 0;
            int numGhostPirates = 0;
            int numMutantShark = 0;
            int numTerminator = 0;
            int numSubmarine = 0;

            if (gameMode == GameMode.SurvivalMode)
            {
                numShootingEnemies = GameConstants.SurvivalModeMaxShootingEnemy;
                numCombatEnemies = GameConstants.SurvivalModeMaxCombatEnemy;
                numGhostPirates = GameConstants.SurvivalModeMaxGhostPirate;
                numMutantShark = GameConstants.SurvivalModeMaxMutantShark;
                numTerminator = GameConstants.SurvivalModeMaxTerminator;
                numSubmarine = GameConstants.SurvivalModeMaxSubmarine;
            }
            else if (gameMode == GameMode.MainGame)
            {
                numShootingEnemies = GameConstants.NumberShootingEnemies[currentLevel];
                numCombatEnemies = GameConstants.NumberCombatEnemies[currentLevel];
                numGhostPirates = GameConstants.NumberGhostPirate[currentLevel];
                numMutantShark = GameConstants.NumberMutantShark[currentLevel];
                numTerminator = GameConstants.NumberTerminator[currentLevel];
                numSubmarine = GameConstants.NumberSubmarine[currentLevel];
            }
            else if (gameMode == GameMode.ShipWreck)
            {
                numGhostPirates = GameConstants.ShipNumberGhostPirate[PlayGameScene.currentLevel];
            }
            Random rnd = new Random();
            for (int i = 0; i < enemiesAmount; i++) {
                if (i < numShootingEnemies)
                {
                    enemies[i] = new ShootingEnemy();
                    enemies[i].Name = "Shooting Enemy";
                    enemies[i].LoadContent(Content, "Models/EnemyModels/diver_green_ly");
                    enemies[i].Load(1, 25, 24);
                }
                else if (i < numShootingEnemies + numCombatEnemies){
                    enemies[i] = new CombatEnemy();
                    enemies[i].Name = "Combat Enemy";
                    enemies[i].LoadContent(Content, "Models/EnemyModels/diver_knife_orange_yellow");
                    enemies[i].Load(1, 30, 24);// 31 60 for attack
                }
                else if (i < numShootingEnemies + numCombatEnemies + numGhostPirates)
                {
                    enemies[i] = new GhostPirate();
                    enemies[i].Name = "Ghost Pirate";
                    enemies[i].LoadContent(Content, "Models/EnemyModels/skeletonrigged");
                    enemies[i].Load(10, 40, 24);
                }
                else if (i < numShootingEnemies + numCombatEnemies + numGhostPirates + numMutantShark)
                {
                    MutantShark mutantShark = new MutantShark();
                    mutantShark.LoadContent(Content, "Models/EnemyModels/mutantSharkVer2");
                    mutantShark.Name = "mutant shark";
                    enemies[i] = mutantShark;
                }
                else if (i < numShootingEnemies + numCombatEnemies + numGhostPirates + numMutantShark + numTerminator)
                {
                    Terminator terminator = new Terminator(gameMode);
                    terminator.LoadContent(Content, "Models/EnemyModels/terminator");
                    if (currentLevel == 4 && gameMode == GameMode.MainGame) terminator.Name = "???";
                    else terminator.Name = "terminator";
                    terminator.Load(31, 60, 24);
                    enemies[i] = terminator;
                }
                else if (i < numShootingEnemies + numCombatEnemies + numGhostPirates + numMutantShark + numTerminator + numSubmarine)
                {
                    Submarine submarine = new Submarine(gameMode);
                    submarine.LoadContent(Content, "Models/EnemyModels/submarine");
                    submarine.Name = "Shark Submarine";
                    submarine.Load(21, 30, 24);
                    enemies[i] = submarine;
                }
            }
        }
示例#18
0
文件: Submarine.cs 项目: khoatle/game
 public void ReleaseHunter(BoundingFrustum cameraFrustum, SwimmingObject[] enemies, ref int enemyAmount, SwimmingObject[] fishes, int fishAmount, HydroBot hydroBot)
 {
     if (!clipPlayer.inRange(31, 40))
         clipPlayer.switchRange(31, 40);
     if (clipPlayer.donePlayingAnimation)
     {
         bool releaseOnRightSide;
         for (int i = 0; i < numHunterGeneratedAtOnce; i++)
         {
             enemies[enemyAmount] = new ShootingEnemy();
             enemies[enemyAmount].Name = "Shooting Enemy";
             enemies[enemyAmount].LoadContent(PoseidonGame.contentManager, "Models/EnemyModels/diver_green_ly");
             enemies[enemyAmount].releasedFromSubmarine = true;
             ((BaseEnemy)enemies[enemyAmount]).Load(1, 25, 24);
             if (i % 2 == 0) releaseOnRightSide = true;
             else releaseOnRightSide = false;
             if (PlaceHunter(enemies[enemyAmount], hydroBot, (BaseEnemy[])enemies, enemyAmount, (Fish[])fishes, fishAmount, releaseOnRightSide))
             {
                 enemyAmount++;
                 numHunterGenerated++;
             }
             else
             {
                 enemies[enemyAmount] = null;
                 break;
             }
         }
         if (!clipPlayer.inRange(11, 20))
             clipPlayer.switchRange(11, 20);
         releasingHunter = false;
     }
 }
示例#19
0
    public void EnemyHit(GameObject enemy, Vector3 bulletPos, Quaternion bulletRot)
    {
        GameMaster.Instance.Freeze(freezeDuration);
        if (freezeDuration < .15f)
        {
            freezeDuration += addFreezeDuration;
        }

        if (ReadWriteSaveManager.Instance.GetData("CanFlash", true, false))
        {
            var flashInst = Instantiate(flashObj, bulletPos, Quaternion.identity);
            Destroy(flashInst.gameObject, .25f);

            GameMaster.Instance.ChangeBackColor(colorNum);
            if (colorNum < .35f)
            {
                colorNum += .05f;
            }
        }

        AudioManager.Instance.Play("EnemyHit", hitPitch);
        hitPitch += .05f;

        HomingEnemy   homing   = enemy.GetComponent <HomingEnemy>();
        ShootingEnemy shooting = enemy.GetComponent <ShootingEnemy>();
        SittingEnemy  sitting  = enemy.GetComponent <SittingEnemy>();
        DashingEnemy  dashing  = enemy.GetComponent <DashingEnemy>();

        if (homing)
        {
            scoreText.SetScore(addScoreHomingHit + addScoreStacking);
            comboUI.SetCounter(addScoreHomingHit + addScoreStacking, homing.transform.position);
            homing.DamageEnemy();
            defeatedHoming = true;
        }
        else if (shooting)
        {
            scoreText.SetScore(addScoreShootingHit + addScoreStacking);
            comboUI.SetCounter(addScoreShootingHit + addScoreStacking, shooting.transform.position);
            shooting.DamageEnemy();
            defeatedShooting = true;
        }
        else if (sitting)
        {
            scoreText.SetScore(addScoreSittingHit + addScoreStacking);
            comboUI.SetCounter(addScoreSittingHit + addScoreStacking, sitting.transform.position);
            sitting.DamageEnemy();
            defeatedSitting = true;
        }
        else if (dashing)
        {
            int dashingAdd = dashing.GetAddScore();
            scoreText.SetScore(addScoreDashingHit + addScoreStacking + dashingAdd);
            comboUI.SetCounter(addScoreDashingHit + addScoreStacking + dashingAdd, dashing.transform.position);
            dashing.DamageEnemy();
            defeatedDashing = true;
        }

        addScoreStacking += 100;
        comboCounter++;
        GameMaster.Instance.SpongeCheckUnlock(comboCounter);
        GameMaster.Instance.BounceCheckUnlock(defeatedHoming, defeatedShooting, defeatedSitting, defeatedDashing);
    }
示例#20
0
    void OnTriggerEnter2D(Collider2D other)
    {
        if (other.CompareTag("Enemy"))
        {
            IncreaseScale();

            GameMaster.Instance.Freeze(freezeDuration);
            if (freezeDuration < .15f)
            {
                freezeDuration += addFreezeDuration;
            }

            if (ReadWriteSaveManager.Instance.GetData("CanFlash", true, false))
            {
                var flashInst = Instantiate(flashObj, other.transform.position, Quaternion.identity);
                Destroy(flashInst.gameObject, .25f);

                GameMaster.Instance.ChangeBackColor(colorNum);
                if (colorNum < .35f)
                {
                    colorNum += .05f;
                }
            }

            AudioManager.Instance.Play("EnemyHit", pitch);
            pitch += .05f;

            HomingEnemy   homingEnemy   = other.gameObject.GetComponent <HomingEnemy>();
            ShootingEnemy shootingEnemy = other.gameObject.GetComponent <ShootingEnemy>();
            SittingEnemy  sittingEnemy  = other.gameObject.GetComponent <SittingEnemy>();
            DashingEnemy  dashingEnemy  = other.gameObject.GetComponent <DashingEnemy>();

            if (homingEnemy)
            {
                scoreText.SetScore(addScoreHomingHit + addScoreStacking);
                comboUI.SetCounter(addScoreHomingHit + addScoreStacking, homingEnemy.transform.position);
                homingEnemy.DamageEnemy();
                defeatedHoming = true;
            }
            else if (shootingEnemy)
            {
                scoreText.SetScore(addScoreShootingHit + addScoreStacking);
                comboUI.SetCounter(addScoreShootingHit + addScoreStacking, shootingEnemy.transform.position);
                shootingEnemy.DamageEnemy();
                defeatedShooting = true;
            }
            else if (sittingEnemy)
            {
                scoreText.SetScore(addScoreSittingHit + addScoreStacking);
                comboUI.SetCounter(addScoreSittingHit + addScoreStacking, sittingEnemy.transform.position);
                sittingEnemy.DamageEnemy();
                defeatedSitting = true;
            }
            else if (dashingEnemy)
            {
                int dashingAdd = dashingEnemy.GetAddScore();
                scoreText.SetScore(addScoreDashingHit + addScoreStacking + dashingAdd);
                comboUI.SetCounter(addScoreDashingHit + addScoreStacking + dashingAdd, dashingEnemy.transform.position);
                dashingEnemy.DamageEnemy();
                defeatedDashing = true;
            }

            addScoreStacking += 100;

            comboCounter++;
            GameMaster.Instance.SpongeCheckUnlock(comboCounter);
            GameMaster.Instance.BounceCheckUnlock(defeatedHoming, defeatedShooting, defeatedSitting, defeatedDashing);
        }

        if (other.CompareTag("Player"))
        {
            PlayerShooting playerShooting = other.GetComponent <PlayerShooting>();

            if (playerShooting.isRecalling || playerShooting.canRecall)
            {
                shake.Shake(shakeDuration, shakeIntensity);
                AudioManager.Instance.Play("PlayerTriHit");
                playerShooting.BulletHit();
                Destroy(parentBul.gameObject);
            }
        }
    }