Inheritance: MonoBehaviour
示例#1
0
 private IEnumerator ExplodeOverTime()
 {
     for (int i = 0; i < detectedEnemies.Count; i++)
     {
         if (detectedEnemies[i] != null)
         {
             toDestroy       = detectedEnemies[i].GetComponent <BaseEnemy>();
             enemyIdentifier = toDestroy.EnemyIdentifier;
             toDestroy.PolyKill(this);
             if (enemyIdentifier == EnemyEnum.Coyote)
             {
                 detectedEnemies[i].AddComponent <BigScalePolyExplosion>();
             }
             else if (enemyIdentifier == EnemyEnum.ChewingGum)
             {
                 detectedEnemies[i].AddComponent <SmallPolyExplosion>();
             }
             else
             {
                 detectedEnemies[i].AddComponent <NormalPolyExplosion>();
             }
             yield return(null);
         }
     }
     detectedEnemies.Clear();
 }
 protected override void CustomHandleImpact(BaseEnemy enemy = null)
 {
     SpriteInstance.TextureScale = 1;
     RotationZ = FlatRedBallServices.Random.Between(-4, 4);
     LightOrShadowSprite.TextureScale = 2f;
     LightOrShadowSprite.Tween(HandleTweenerUpdate, 2f, 0f, SpriteInstance.AnimationChains["Impact"].TotalLength, InterpolationType.Exponential, Easing.Out).Start();
 }
示例#3
0
 protected virtual void Awake()
 {
     if (mEnemy == null)
     {
         mEnemy = GetComponent <BaseEnemy>();
     }
 }
 public BattleAbilityUseHandler(ref BaseCharacterClass character, int playerTargetIndex, ref BaseCharacterClass[] alliedCharacters, ref BaseEnemy[] enemies)
 {
     this.character = character;
     this.playerTargetIndex = playerTargetIndex;
     this.alliedCharacters = alliedCharacters;
     this.enemies = enemies;
 }
示例#5
0
    public void SetHealthBarPlayer()
    {
//		Debug.Log("Healthbar test");
        float myHealth = CurHealth / maxHealth;

//		Debug.Log(curHealth + " current Health");
//		Debug.Log(myHealth);
        if (myHealth <= 0)
        {
            myHealth = 0;
        }
        if (myHealth >= 1)
        {
            myHealth = 1;
        }
        healthBar.transform.localScale = new Vector3(myHealth, healthBar.transform.localScale.y, healthBar.transform.localScale.z);
//		Debug.Log("myHealth " + myHealth);
        GameObject        TileMap = GameObject.Find("Map");
        TileMap           map     = TileMap.GetComponent <TileMap>();
        GameObject        Enemy   = GameObject.Find(map.selectedEnemy);
        BaseEnemy         enemy   = Enemy.GetComponent <BaseEnemy>();
        GameObject        Player  = GameObject.Find(enemy.selectedPlayer);
        PlayableCharacter player  = Player.GetComponent <PlayableCharacter>();

        player.PlayerClass.HpPointsRemaining = (int)(myHealth * player.PlayerClass.HpPointsMax);
    }
示例#6
0
    //Spawns enemies and sets their target
    public void SpawnEnemies()
    {
        if (canSpawn)
        {
            canSpawn = false;
            Transform target = LevelLampsManager.instance.GetNearestFuseLightFuse(transform);
            if (target == null)
            {
                target = FindObjectOfType <PlayerBehaviour>().transform;
            }

            spawnAmount = Random.Range(settings.minNumberSpawned, settings.maxNumberSpawned);
            for (int i = 0; i < spawnAmount; i++)
            {
                if (!GameIntensityManager.instance.GetIsAtCrawlerLimit())
                {
                    int rand;

                    rand = Random.Range(0, settings.enemyTypes.Count);

                    BaseEnemy currEnemy = ObjectPoolManager.Spawn(settings.enemyTypes[rand],
                                                                  (Random.insideUnitCircle * settings.spawnRadius + (Vector2)transform.position), Quaternion.identity).GetComponent <BaseEnemy>();
                    currEnemy.SetTarget(target);
                    if (currEnemy)
                    {
                        GameIntensityManager.instance.IncrementNumberOfCrawlers();
                    }
                }
                else
                {
                    break;
                }
            }
        }
    }
示例#7
0
    //Our usual inspector override
    public override void OnInspectorGUI()
    {
        //DrawDefaultInspector();
        BaseEnemy t = (BaseEnemy)target;

        for (int i = 0; i < t.waypoints.Count; i++)
        {
            EditorGUILayout.BeginHorizontal();
            t.waypoints[i] = EditorGUILayout.Vector3Field(i.ToString(), t.waypoints[i]);
            if (GUILayout.Button("X"))
            {
                EditorApplication.Beep();
                if (EditorUtility.DisplayDialog("Delete Waypoint", "Are you sure you want to delete waypoint " + i.ToString() + "?", "Yes", "No"))
                {
                    Undo.RecordObject(t, "Remove Waypoint");
                    t.waypoints.RemoveAt(i);
                    EditorUtility.SetDirty(t);
                }
            }
            EditorGUILayout.EndHorizontal();
        }

        //Adding a button
        if (GUILayout.Button("Add Waypoint"))
        {
            //Adds a new waypoint using the values of the last waypoint as a start
            Undo.RecordObject(t, "Add Waypoint");
            t.waypoints.Add(t.waypoints[t.waypoints.Count - 1]);
            EditorUtility.SetDirty(t);
        }
    }
示例#8
0
    IEnumerator shoot()
    {
        RaycastHit2D hitinfo = Physics2D.Raycast(firepoint.position, firepoint.right);

        if (hitinfo)
        {
            BaseEnemy enemy = hitinfo.transform.GetComponent <BaseEnemy>();
            if (enemy != null)
            {
                enemy.takedamage(damage);
            }
            Debug.Log(hitinfo.transform.name);

            //Instantiate(impacteffect, hitinfo.point, Quaternion.identity);
            line.SetPosition(0, firepoint.position);
            line.SetPosition(1, hitinfo.point);
        }
        else
        {
            line.SetPosition(0, firepoint.position);
            line.SetPosition(1, firepoint.position + firepoint.right * 100);
        }
        line.enabled = true;
        yield return(0);

        line.enabled = false;
    }
示例#9
0
 public void InitPanel(BaseEnemy character)
 {
     _currentEnemyHealth      = GetComponentInChildren <Text>();
     _currentEnemyNextAction  = GetComponentInChildren <Image>();
     _currentEnemyHealth.text = character.CharacterHealth.ToString();
     //_currentEnemyNextAction.sprite = null;
 }
示例#10
0
 public static void OnEnemyDeath(BaseEnemy enemy)
 {
     if (onEnemyDeath != null)
     {
         onEnemyDeath(enemy);
     }
 }
示例#11
0
    void Fire()
    {
        fireTimer = 0;

        firePoint.LookAt(target);
        drone.LookAt(target);

        droneLR.enabled    = true;
        droneLight.enabled = true;

        droneLR.SetPosition(0, firePoint.position);

        shootRay.origin    = firePoint.position;
        shootRay.direction = firePoint.forward;

        if (Physics.Raycast(shootRay, out shootHit, range, shootableMask))
        {
            BaseEnemy enemyHealth = shootHit.collider.GetComponent <BaseEnemy>();
            if (enemyHealth != null)
            {
                enemyHealth.TakeDamage(damagePerShot, shootHit.point);
            }
            droneLR.SetPosition(1, shootHit.point);
        }
        else
        {
            droneLR.SetPosition(1, shootRay.origin + shootRay.direction * range);
        }
    }
示例#12
0
 public static void OnEnemyArrivedInTown(BaseEnemy enemy)
 {
     if (onEnemyArrivedInTown != null)
     {
         onEnemyArrivedInTown(enemy);
     }
 }
示例#13
0
    private void OnTriggerEnter(Collider other)
    {
        if (other.tag == "Wall")
        {
            PlayerBase.transform.position = new Vector3(PlayerRef.StartPos.x, PlayerRef.StartPos.y, PlayerRef.StartPos.z);
        }

        if (other.tag == "Enemy")
        {
            EnemyRef = other.GetComponent <BaseEnemy>();
            if (!EnemyRef.Attacked)
            {
                EnemiesHit.Add(other.GetComponent <BaseEnemy>());
                EnemyRef.Attacked = true;
                IDamage DamRef = other.GetComponent <IDamage>();
                if (DamRef != null)
                {
                    DamRef.TakeDamage(SkillManager.Instance.DashDamage);
                    DamRef.SetDamageText(SkillManager.Instance.DashDamage, false);
                }
                EnemyRef.DamEffect(DamageEffects.ElectricEffect);
                StartCoroutine(ResetAttacked());
            }
        }
    }
示例#14
0
        public void AttachTo(BaseEnemy npc)
        {
            _npc        = npc;
            _npc.OnDie += Die;

            _animator = GetComponent <Animator>();
        }
        public Action <TimeSpan, IBasePlayer> GetTimedAction(BaseEnemy enemy, IBasePlayer player, BaseVerticalShooter.GameModel.IBaseMap gameMap)
        {
            var action = new Action <TimeSpan, IBasePlayer>((t, p) =>
            {
                if (enemy.State == CharacterState.Alive)
                {
                    if (accumulatedTime > Milestones.Last().End)
                    {
                        accumulatedTime = TimeSpan.FromSeconds(0);
                    }

                    var milestone    = GetCurrentMilestone();
                    this.RoutineType = milestone.RoutineType;

                    var milestoneExists = (milestone.Start != milestone.End);
                    if (milestoneExists && milestone.RoutineType == RoutineType.Walk)
                    {
                        Walk(enemy, gameMap, t);
                    }

                    accumulatedTime = accumulatedTime.Add(t);
                    enemy.CheckReload();
                }
            });

            return(action);
        }
示例#16
0
    void UpdateTarget()
    {
        GameObject[] enemies          = GameObject.FindGameObjectsWithTag(enemyTag);
        float        shortestDistance = Mathf.Infinity;
        GameObject   nearestEnemy     = null;

        foreach (GameObject enemy in enemies)
        {
            float distanceToEnemy = Vector3.Distance(transform.position, enemy.transform.position);
            if (distanceToEnemy < shortestDistance)
            {
                shortestDistance = distanceToEnemy;
                nearestEnemy     = enemy;
            }
        }

        if (nearestEnemy != null && shortestDistance <= range)
        {
            target      = nearestEnemy.transform;
            targetEnemy = nearestEnemy.GetComponent <BaseEnemy>();
        }
        else
        {
            target = null;
        }
    }
示例#17
0
 protected virtual void Awake()
 {
     if(mEnemy == null)
     {
         mEnemy = GetComponent<BaseEnemy>();
     }
 }
示例#18
0
 public void OnEnemyTouch(BaseEnemy enemy)
 {
     if (Vulnerable)
     {
         Hurt(enemy.TouchDamage);
     }
 }
示例#19
0
    public override void ExSkill()
    {
        //do damage on all enemies
        Debug.Log("Fire Mage do damage on all enemies");

        if (HeroAnimator != null)
        {
            HeroAnimator.SetBool("Skill", true);
        }
        PlayerStats.Energy -= energyCostBySkill;
        particleEffect.Play();
        fireEffect.Play();

        GameObject[] enemies = GameObject.FindGameObjectsWithTag(enemyTag);
        //Debug.Log("Number of enemies: " + enemies.Length);
        if (enemies != null && enemies.Length > 0)
        {
            float amount = 1.85f * MATKValue;
            foreach (GameObject enemy in enemies)
            {
                BaseEnemy te = enemy.GetComponent <BaseEnemy>();
                //Debug.Log(te.CurHP + ", " + amount);
                te.TakeDamage(amount);
            }
        }

        StartCoroutine("SkillDuration");
    }
示例#20
0
    void OnTriggerEnter(Collider col)
    {
        BaseBossEnemy boss = col.transform.GetComponent <BaseBossEnemy>();

        if (boss != null)
        {
            return;
        }

        BaseEnemy target = col.transform.GetComponent <BaseEnemy>();

        if (target != null && agent.isStopped == false)
        {
            NearTarget = target.gameObject;

            IsStop   = true;
            isAttack = true;
        }

        if (NearTarget == null)
        {
            return;
        }

        Hole colHole    = col.GetComponent <Hole>();
        Hole targetHole = NearTarget.GetComponent <Hole>();

        if (colHole != null && targetHole != null && colHole == targetHole)
        {
            NearTarget = null;
        }
    }
示例#21
0
    protected override bool Attack()
    {
        Collider[] enemiesInRange = Physics.OverlapSphere(transform.position, range);
        if (enemiesInRange.Length == 0)
        {
            return(false);
        }

        bool enemyHit = false;

        foreach (Collider collider in enemiesInRange)
        {
            BaseEnemy enemy = collider.GetComponent <BaseEnemy>();
            if (enemy != null)
            {
                enemy.Hit(stats);
                enemyHit = true;
            }
        }

        if (!enemyHit)
        {
            return(false);
        }

        hitAnimationObject.GetComponent <Animation>().Play();
        return(true);
    }
示例#22
0
    private IEnumerator _SpawnEnemyTimer()
    {
        while (_enemiesToLoad.Count > 0)
        {
            EnemyData enemy = _enemiesToLoad.Dequeue();

            List <EnemyData> enemies         = _enemiesToLoad.ToList();
            List <EnemyData> enemiesSpawning = new List <EnemyData>();
            enemiesSpawning.Add(enemy);

            foreach (EnemyData en in enemies)
            {
                if (en.timeToSpawn == enemy.timeToSpawn)
                {
                    enemiesSpawning.Add(en);
                    _enemiesToLoad.Dequeue();
                }
            }

            float timeToSpawn = enemy.timeToSpawn - _oldTimeToLoad;
            yield return(new WaitForSeconds(timeToSpawn));

            _oldTimeToLoad = enemy.timeToSpawn;
            foreach (EnemyData e in enemiesSpawning)
            {
                float   xPos = Screen.width * ((float)e.spawnPosition / 100);
                float   yPos = Screen.height + (Screen.height / 5);
                Vector3 pos  = Camera.main.ScreenToWorldPoint(new Vector3(xPos, yPos, 10f));

                BaseEnemy.CreateEnemy(_manager, e.name, pos);
            }
            enemiesSpawning.Clear();
        }
    }
示例#23
0
        public async void AnimateEnemyHurt(BaseEnemy enemyInstance, int damage)
        {
            SpawnEnemyDamageLabel(damage);
            enemyImage.Shake(1, 15, 1);

            var region         = ((AtlasTexture)enemyImage.Texture).Region;
            var regionPosition = region.Position;

            regionPosition.x = CombatAnimationUtil
                               .AnimationStateRegionPositionX[CombatAnimationUtil.AnimationState.Hurt];

            if (enemyInstance.Health > 0)
            {
                await ToSignal(GetTree().CreateTimer(1), "timeout");

                regionPosition.x = CombatAnimationUtil
                                   .AnimationStateRegionPositionX[
                    CombatAnimationUtil.AnimationState.Normal];
            }
            else
            {
                var modulate = enemyImage.Modulate;
                modulate.a          = 0;
                enemyImage.Modulate = modulate;
            }

            region.Position = regionPosition;
            ((AtlasTexture)enemyImage.Texture).Region = region;
        }
    public void Fire()
    {
        fireTimer = 0;

        curClipSize--;

        gunLR.enabled    = true;
        gunLight.enabled = true;

        gunLR.SetPosition(0, firePoint.position);

        shootRay.origin    = firePoint.position;
        shootRay.direction = firePoint.forward;

        if (Physics.Raycast(shootRay, out shootHit, range, shootableMask))
        {
            BaseEnemy enemyHealth = shootHit.collider.GetComponent <BaseEnemy>();
            if (enemyHealth != null)
            {
                enemyHealth.TakeDamage(damagePerShot, shootHit.point);
            }
            gunLR.SetPosition(1, shootHit.point);
        }
        else
        {
            gunLR.SetPosition(1, shootRay.origin + shootRay.direction * range);
        }

        if (curClipSize == 0)
        {
            noAmmo = true;
            return;
        }
    }
示例#25
0
    void OnCollisionEnter2D(Collision2D enemy)
    {
        if (enemy.gameObject.tag == "Enemy" || enemy.gameObject.tag == "Hot Head")
        {
            BaseEnemy mob = enemy.gameObject.GetComponent <BaseEnemy>();

            if (canAbsorb == true)
            {
                if (enemy.gameObject.tag == "Hot Head")
                {
                    form = AttackForm.Fire;
                }

                mob.Die();
                currentState = State.Full;
                anim.SetBool("Suck", false);
                anim.SetBool("Full", true);
                score += mob.pointValue;
            }
            else
            {
                dmgTaken = mob.atkDmg;
                TakeDamage(dmgTaken);
                mob.Die();
            }
            scoreText.text = "Score : " + score;
        }
    }
示例#26
0
        private void OnEnemyDie(BaseEnemy enemy)
        {
            enemy.EnemyDieEvent -= OnEnemyDie;
            enemiesDeadCount    += 1;

            CheckLevel();
        }
示例#27
0
    private void OnParticleTrigger()
    {
        var hits = new List <ParticleSystem.Particle>();

        particles.GetTriggerParticles(ParticleSystemTriggerEventType.Enter, hits);
        if (hits.Count == 0)
        {
            return;
        }
        foreach (var hit in hits)
        {
            var collision = Physics2D.OverlapCircle(new Vector2(hit.position.x, hit.position.y), 1.5f, layer);
            if (collision)
            {
                BaseEnemy enemy = collision.GetComponentInParent <BaseEnemy>();
                Debug.Log(collision);
                if (enemy != null && !enemy.hasBeenHit)
                {
                    int dmg = Info.CalculateDamage(enemy.stats, out bool crit);
                    enemy.OnGetHit(dmg, crit);
                    StartCoroutine(enemy.HasBeenHit(Info.attackInterval));
                    break;
                }
            }
        }
    }
示例#28
0
    private void SpawnEnemy(GameObject prefab)
    {
        GameObject newEnemy  = Instantiate(prefab, GetRandomSpawnTransform(), Quaternion.identity);
        BaseEnemy  baseEnemy = newEnemy.GetComponent <BaseEnemy>();

        baseEnemy.StartActing();
    }
示例#29
0
        public IEnumerator EachEnemyWave(EnemyBornMsg bornMsg, int bornPointID, int bornPathID)
        {
            if (bornMsg.enemys.Count < 1)
            {
                yield break;
            }
            if (bornMsg.enemys.Count == 1)
            {
                GameObject enemy     = AssestManager.Instance.LoadEnemy(bornMsg.enemys[0].type);
                BaseEnemy  baseEnemy = enemy.GetComponent <BaseEnemy>();
                baseEnemy.PathID = bornPathID;
                for (int i = 0; i < bornMsg.enemys[0].num; i++)
                {
                    InstantiateEnemy(bornMsg.enemys[0].type, bornPointID, bornPathID);

                    Debug.Log($"1  intervalTime {bornMsg.intervalTime}");
                    yield return(new WaitForSeconds(bornMsg.intervalTime));
                }
            }
            else
            {
                for (int i = 0; i < bornMsg.enemys.Count; i++)
                {
                    EnemyDetail enemy = bornMsg.enemys[i];
                    StartCoroutine(YieldInstantiateEnemy(enemy.type, enemy.num, bornPointID, bornPathID));
                    Debug.Log($"2  intervalTime {bornMsg.intervalTime}");
                    yield return(new WaitForSeconds(bornMsg.intervalTime));
                }
            }
        }
示例#30
0
    /// <summary>
    /// Spawns the boss.
    /// </summary>
    protected void SpawnBoss()
    {
        // Check if checkpoint is allowed to spawn.
        if (GameManager.GameManagerInstance.WaveActive && spawnAllowed && GameManager.GameManagerInstance.CurrentEnemyCount < 1)
        {
            // Check the deactivation distance and the minimum distance.
            if (curentDistanceToPlayer > deactivationDistance && curentDistanceToPlayer < minDistanceToPlayer)
            {
                // Instantiate enemy.
                GameObject boss = Instantiate(GameManager.GameManagerInstance.BossSpawnInfo.boss,
                                              PlayerMiddlePoint, GameManager.GameManagerInstance.BossSpawnInfo.boss.transform.rotation) as GameObject;

                boss.SetActive(false);
                boss.name = GameManager.GameManagerInstance.BossSpawnInfo.enemyName;

                boss.transform.position = transform.position;
                boss.SetActive(true);

                // Set increased health and attack
                BaseEnemy e = boss.GetComponent <MonoBehaviour>() as BaseEnemy;

                e.MaxHealth = GameManager.GameManagerInstance.BossSpawnInfo.ActualHealth;
                e.Health    = GameManager.GameManagerInstance.BossSpawnInfo.ActualHealth;

                // Trigger event.
                OnEnemySpawn();

                //Decrease ressource pool
                GameManager.GameManagerInstance.CurrentEnemyRessourceValue -= GameManager.GameManagerInstance.BossSpawnInfo.enemyRessourceValue;

                spawnAllowed = false;
                StartCoroutine(WaitForNextSpawn());
            }
        }
    }
示例#31
0
    private void OnTriggerEnter(Collider other)
    {
        // Ignore collision with the camera raycast plane
        if (other.CompareTag("CameraRaycastPlane"))
        {
            return;
        }

        // Damage the enemy if we hit one
        BaseEnemy enemy = other.GetComponent <BaseEnemy>();

        if (enemy != null)
        {
            // Prevent damaging dead enemies and don't destroy the projectile
            // if it hit a dead enemy
            if (!enemy.IsAlive)
            {
                return;
            }

            enemy.TakeDamage(RangedWeapon.Damage);
        }

        // Destroy the projectile once it has hit something
        Destroy(gameObject);
    }
示例#32
0
    void HitEnemy()
    {
        GameObject CardDropArea = GameObject.Find("CardDropArea");
        DropZone   dropZone     = CardDropArea.GetComponent <DropZone>();

        GameObject[] Enemies = GameObject.FindGameObjectsWithTag("Enemy");
        foreach (GameObject Enemy in Enemies)
        {
            BaseEnemy     enemy = Enemy.GetComponent <BaseEnemy> ();
            GameObject    Tile  = GameObject.Find("Hex_" + enemy.TileX + "_" + enemy.TileY);
            ClickableTile tile  = Tile.GetComponent <ClickableTile> ();
            if (tile.willTakeHit)
            {
                enemy.Recentlyhit = true;
                HealthBar enemyHpBar = enemy.GetComponent <HealthBar> ();
                //TODO
                //if lauseke johonkin, joka tarkistaa onko kyseess' physDMG vai magic DMG
                enemyHpBar.CurHealth -= (dropZone.damage / enemy.HpPointsMax) * (100 * (enemy.PhysDmgReduction + enemy.MagicDmgReduction));
                enemyHpBar.SetHealthBarEnemy();
                enemyHpBar.parentName = Enemy.name;
                enemyHpBar.KillUnit();
                tile.willTakeHit = false;
            }
        }
    }
示例#33
0
 public static void ReleaseEnemy(BaseEnemy enemy)
 {
     if (enemy != null)
     {
         Queue<BaseEnemy> availableEnemy = EnemyFactory.Instance.availableEnemyByType[enemy.Type];
         enemy.gameObject.SetActive(false);
         availableEnemy.Enqueue(enemy);
     }
 }
示例#34
0
    public void InitDOT(float duration, float damageInterval, float damagePerInterval)
    {
        _target = gameObject.GetComponent<BaseEnemy>();
        _particleEffectPrefab = (GameObject) Resources.Load("FireDOTParticle", typeof(GameObject));

        StartCoroutine(DoDOT(duration, damageInterval, damagePerInterval));
        _particleEffect = (GameObject) Instantiate(_particleEffectPrefab, transform.position, Quaternion.identity);
        _particleEffect.transform.parent = gameObject.transform;
    }
 public void ScaleEnemy(BaseEnemy enemy)
 {
     int playerLevel = GameControl.control.playerLevel;
     enemy.maxHealth = enemy.maxHealth + (Mathf.CeilToInt(enemy.maxHealth / 4.0f) * Mathf.FloorToInt(playerLevel / 5.0f));
     enemy.currentHealth = enemy.currentHealth + (Mathf.CeilToInt(enemy.currentHealth/4.0f) * Mathf.FloorToInt(playerLevel/5.0f));
     enemy.damageGiven = enemy.damageGiven;
     enemy.experienceGiven = enemy.experienceGiven;
     enemy.entityMovement.maxSpeed = enemy.entityMovement.maxSpeed;
     enemy.entityMovement.maxMaxSpeed = enemy.entityMovement.maxMaxSpeed;
 }
示例#36
0
 /*
     For testing purposes. Attacks the unit with highest presence
 */
 public static Entity biggestPresenceStrategy(BaseCharacterClass[] characters, BaseEnemy[] enemies)
 {
     BaseCharacterClass target = characters[0];
     for (int i = 1; i < characters.Length; i++)
     {
         if (target.presence < characters[i].presence)
         {
             target = characters[i];
         }
     }
     return target;
 }
示例#37
0
    /*
        Generates random enemies and queues them into the speed queue
    */
    private void queueAllEnemies()
    {
        int numberOfEnemies = 4;
        enemies = new BaseEnemy[numberOfEnemies];
        enemies[0]  = new BaseEnemy("Alan", 3, EnemyStrategies.biggestPresenceStrategy);
        enemies[1]  = new BaseEnemy("Pedro", 4, EnemyStrategies.randomStrategy);
        enemies[2]  = new BaseEnemy("Niko", 5, EnemyStrategies.purePresenceStrategy);
        enemies[3]  = new BaseEnemy("Andy", 7, EnemyStrategies.purePresenceStrategy);

        foreach (BaseEnemy e in enemies)
        {
            pq.Enqueue(new QueuedEntity(e), e.speed);
        }
    }
示例#38
0
    /*
        Attacks based on presence
    */
    public static Entity purePresenceStrategy(BaseCharacterClass[] characters, BaseEnemy[] enemies)
    {
        int totalPresence = 0;
        foreach (BaseCharacterClass c in characters) {
            totalPresence += c.presence;
        }

        int random = Random.Range(0, totalPresence);
        int presenceAccumulator = 0;
        foreach (BaseCharacterClass c in characters)
        {
            int characterPresence = c.presence;
            if (random <= characterPresence + presenceAccumulator)
            {
                return c;
            }
            presenceAccumulator += characterPresence;
        }
        // Should never reach this case!
        return null;
    }
示例#39
0
 public void OnDestroyEnemy(BaseEnemy enemy)
 {
     findedEnemys.Remove(enemy);
 }
 void Awake() {
     startPosition = transform.position;
     startRotation = transform.rotation;
     animator = GetComponent<Animator>();
     baseEnemy = this.GetComponent<BaseEnemy>();
 }
 void Start()
 {
     thisEnemy = gameObject.GetComponent<BaseEnemy>();
     StartingHP = thisEnemy.BaseHealth;
 }
示例#42
0
 public static BaseEnemy CreateNewEnemy()
 {
     enemySelection = Random.Range(1,6);
     curEnemy = EnemyList.ChooseEnemy(enemySelection);
     return curEnemy;
 }
示例#43
0
 public void OnGetHit(BaseEnemy enemy, Collider2D other)
 {
     OnGetHit((int)enemy.damage, (FeetCollider.bounds.center - other.bounds.center).normalized);
 }
示例#44
0
 /*
     Simplest of strategies, attacks a random character.
 */
 public static Entity randomStrategy(BaseCharacterClass[] characters, BaseEnemy[] enemies)
 {
     return characters[Random.Range(0, characters.Length - 1)];
 }
示例#45
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>
    protected override void Start()
    {
        base.Start ();

        enemyBehavior = GetComponent<BaseEnemy> ();

        hitAgainstAttackTag = AttackTag.PlayerAttack;

        originalColor = renderer.material.color;
        hitColor = Color.red;
    }
示例#46
0
    public void OnGetHit(BaseEnemy enemy, Collider2D other)
    {
        if (afterOnHurt) return;

        Vector2 d = (FeetCollider.bounds.center - other.bounds.center).normalized;
        OnGetHit((int)enemy.damage, d, other);
    }
示例#47
0
    void BeforeDie(BaseEnemy enemy_)
    {
		GetComponent<AudioSource> ().PlayOneShot (audio [0]);
        if (_capsule != null)
        {
            _capsule.enabled = false;
        }
    }
示例#48
0
        public static void DrawObjectPointedAtStatus(GraphicsDevice graphicsDevice, Cursor cursor, Camera gameCamera, Game game, SpriteBatch spriteBatch, Fish[] fish, int fishAmount, BaseEnemy[] enemies, int enemiesAmount, List<Trash> trashes, List<ShipWreck> shipWrecks, List<Factory> factories, ResearchFacility researchFacility, List<TreasureChest> treasureChests, List<Powerpack> powerPacks, List<Resource> resources)
        {
            bool somethingPointedAt = false;
            string name = "";
            Vector3 position = Vector3.Zero;
            //Display Fish Health
            Fish fishPointedAt = CursorManager.MouseOnWhichFish(cursor, gameCamera, fish, fishAmount);
            if (fishPointedAt != null)
            {
                swimmingObjName = fishPointedAt.Name;
                swimmingObjHealth = (int)fishPointedAt.health;
                swimmingObjMaxHealth = (int)fishPointedAt.maxHealth;
                IngamePresentation.DrawHealthBar(game, spriteBatch, statsFont, swimmingObjHealth, swimmingObjMaxHealth, 5, swimmingObjName, 1.0f);
                //string fishTalk;
                fishTalk = "'";
                if (fishPointedAt.health < 20)
                {
                    fishTalk += "SAVE ME!!!";
                }
                else if (fishPointedAt.health < 60)
                {
                    fishTalk += IngamePresentation.wrapLine(fishPointedAt.sad_talk, commentMaxLength, fishTalkFont, textScaleFactor);
                }
                else
                {
                    fishTalk += IngamePresentation.wrapLine(fishPointedAt.happy_talk, commentMaxLength, fishTalkFont, textScaleFactor);
                }
                fishTalk += "'";
                spriteBatch.DrawString(fishTalkFont, fishTalk, new Vector2(game.Window.ClientBounds.Width / 2, 4 + (fishTalkFont.MeasureString(swimmingObjName).Y + fishTalkFont.MeasureString(fishTalk).Y / 2 + lineSpacing) * textScaleFactor), Color.Yellow, 0, new Vector2(fishTalkFont.MeasureString(fishTalk).X / 2, fishTalkFont.MeasureString(fishTalk).Y / 2), textScaleFactor, SpriteEffects.None, 0);
                somethingPointedAt = true;
                fishWasPointedAt = true;
                enemyWasPointedAt = nonLivingObjWasPointedAt = false;
            }
            else
            {
                //fishWasPointedAt = false;
                //Display Enemy Health
                BaseEnemy enemyPointedAt = CursorManager.MouseOnWhichEnemy(cursor, gameCamera, enemies, enemiesAmount);
                if (enemyPointedAt != null)
                {
                    swimmingObjName = enemyPointedAt.Name;
                    swimmingObjHealth = (int)enemyPointedAt.health;
                    swimmingObjMaxHealth = (int)enemyPointedAt.maxHealth;
                    IngamePresentation.DrawHealthBar(game, spriteBatch, statsFont, swimmingObjHealth, swimmingObjMaxHealth, 5, swimmingObjName, 1.0f);
                    somethingPointedAt = true;
                    enemyWasPointedAt = true;
                    fishWasPointedAt = nonLivingObjWasPointedAt = false;
                }
                else
                {
                    //enemyWasPointedAt = false;
                    line = comment = tip = tip2 = "";
                    Powerpack powerPackPointedAt = null, botOnPowerPack = null;
                    CursorManager.MouseOnWhichPowerPack(cursor, gameCamera, powerPacks, ref powerPackPointedAt, ref botOnPowerPack, null);
                    if (powerPackPointedAt != null)
                    {
                        line = "";
                        comment = "";
                        if (powerPackPointedAt.powerType == PowerPackType.Speed)
                        {
                            line = "SPEED BOOST POWERPACK";
                            name = "Speed Boost Powerpack";
                            comment = "Temporarily doubles Hydrobot's movement speed.";
                        }
                        else if (powerPackPointedAt.powerType == PowerPackType.Strength)
                        {
                            line = "STRENGTH BOOST POWERPACK";
                            name = "Strength Boost Powerpack";
                            comment = "Temporarily doubles Hydrobot's power.";
                        }
                        else if (powerPackPointedAt.powerType == PowerPackType.FireRate)
                        {
                            line = "SHOOT RATE BOOST POWERPACK";
                            name = "Shoot Rate Boost Powerpack";
                            comment = "Temporarily doubles Hydrobot's shooting speed.";
                        }
                        else if (powerPackPointedAt.powerType == PowerPackType.Health)
                        {
                            line = "HEALTH BOOST POWERPACK";
                            name = "Health Boost Powerpack";
                            comment = "Replenishes Hydrobot's health.";
                        }
                        else if (powerPackPointedAt.powerType == PowerPackType.StrangeRock)
                        {
                            line = "STRANGE ROCK";
                            name = "Strange Rock";
                            comment = "A rock that exhibits abnormal characteristics. Can be dropped at Research Center for analysing.";
                        }
                        else if (powerPackPointedAt.powerType == PowerPackType.GoldenKey)
                        {
                            line = "GOLDEN KEY";
                            name = "Golden Key";
                            comment = "Can open any treasure chest.";
                        }
                        position = powerPackPointedAt.Position;
                        tip = "Press Z to collect";
                    }
                    else
                    {
                        Resource resourcePointedAt = null, botOnResource = null;
                        CursorManager.MouseOnWhichResource(cursor, gameCamera, resources, ref resourcePointedAt, ref botOnResource, null);
                        if (resourcePointedAt != null)
                        {
                            line = "RECYCLED RESOURCE BOX";
                            name = "Recycled Resource Box";
                            comment = "A box contains recycled resource produced by the processing plant. Recycled resources can be used to construct new facilities.";
                            tip = "Press Z to collect";
                            position = resourcePointedAt.Position;
                        }
                        else
                        {
                            TreasureChest chestPointedAt = CursorManager.MouseOnWhichChest(cursor, gameCamera, treasureChests);
                            if (chestPointedAt != null)
                            {
                                line = "TREASURE CHEST";
                                name = "Treasure Chest";
                                comment = "Contains valuables sunk with the ship hundreds years ago.";
                                tip = "Double click to open";
                                position = chestPointedAt.Position;
                            }
                            Trash trashPointedAt = null, botOnTrash = null;
                            CursorManager.MouseOnWhichTrash(cursor, gameCamera, trashes, ref trashPointedAt, ref botOnTrash, null);
                            if (trashPointedAt != null)
                            {
                                line = "";
                                comment = "";
                                if (trashPointedAt.trashType == TrashType.biodegradable)
                                {
                                    line += "BIODEGRADABLE WASTE";
                                    name = "Biodegradable Waste";
                                    comment = "Great source of renewable energy.";
                                    tip = "Press Z to collect";
                                }
                                else if (trashPointedAt.trashType == TrashType.plastic)
                                {
                                    line += "PLASTIC WASTE";
                                    name = "Plastic Waste";
                                    comment = "May take more than 500 years to decompose.";
                                    tip = "Press X to collect";
                                }
                                else
                                {
                                    line += "RADIOACTIVE WASTE";
                                    name = "Radioactive Waste";
                                    comment = "An invisible speck can cause cancer.";
                                    tip = "Press C to collect";
                                }
                                position = trashPointedAt.Position;
                            }
                            else
                            {
                                ShipWreck shipPointedAt = CursorManager.MouseOnWhichShipWreck(cursor, gameCamera, shipWrecks);
                                if (shipPointedAt != null)
                                {
                                    line = "";
                                    comment = "";
                                    line = "OLD SHIPWRECK";
                                    name = "Old Shipwreck";
                                    comment = "Sunk hundreds years ago.";
                                    tip = "Double click to enter";
                                    position = shipPointedAt.Position;
                                }
                                else
                                {
                                    Factory factoryPointedAt = CursorManager.MouseOnWhichFactory(cursor, gameCamera, factories);
                                    if (factoryPointedAt != null)
                                    {
                                        line = "";
                                        comment = "";
                                        if (factoryPointedAt.factoryType == FactoryType.biodegradable)
                                        {
                                            line += "BIODEGRADABLE WASTE PROCESSING PLANT";
                                            name = "Biodegradable Waste Processing Plant";
                                            comment = "Organic wastes can be dropped here for processing.";
                                        }
                                        else if (factoryPointedAt.factoryType == FactoryType.plastic)
                                        {
                                            line += "PLASTIC WASTE PROCESSING PLANT";
                                            name = "Plastic Waste Processing Plant";
                                            comment = "Plastic wastes can be dropped here for processing.";
                                        }
                                        else
                                        {
                                            line += "RADIOACTIVE WASTE PROCESSING PLANT";
                                            name = "Radioactive Waste Processing Plant";
                                            comment = "Radioactive wastes can be dropped here for processing.";
                                        }

                                        position = factoryPointedAt.Position;
                                        tip = "Double click to drop collected wastes";
                                        tip2 = "Shift + Click to open control panel";
                                    }
                                    else
                                    {
                                        if (CursorManager.MouseOnResearchFacility(cursor, gameCamera, researchFacility))
                                        {
                                            line = "RESEARCH FACILITY";
                                            name = "Research Facility";
                                            position = researchFacility.Position;
                                            comment = "Researches on upgrading plants and Hydrobot, analysing abnormal objects and resurrecting extinct animals from DNA.";
                                            tip = "Double click to drop collected objects";
                                            tip2 = "Shift + Click to open control panel";
                                        }
                                    }
                                }
                            }
                        }
                    }
                    //draw name right over obj pointed at
                    if (GameSettings.ShowLiveTip && name != "")
                    {
                        Vector3 screenPos = graphicsDevice.Viewport.Project(position - new Vector3(0, 0, 20), gameCamera.ProjectionMatrix, gameCamera.ViewMatrix, Matrix.Identity);
                        Vector2 twoDPos;
                        twoDPos.X = screenPos.X;
                        twoDPos.Y = screenPos.Y;
                        spriteBatch.DrawString(IngamePresentation.fishTalkFont, name, twoDPos, Color.Gold, 0,
                            new Vector2(IngamePresentation.fishTalkFont.MeasureString(name).X / 2, IngamePresentation.fishTalkFont.MeasureString(name).Y / 2), IngamePresentation.textScaleFactor, SpriteEffects.None, 0);
                        if (tip != "")
                            spriteBatch.DrawString(IngamePresentation.fishTalkFont, tip, twoDPos + new Vector2(0, IngamePresentation.fishTalkFont.MeasureString(name).Y / 2 + 5 + IngamePresentation.fishTalkFont.MeasureString(tip).Y / 2) * IngamePresentation.textScaleFactor, Color.White, 0,
                                new Vector2(IngamePresentation.fishTalkFont.MeasureString(tip).X / 2, IngamePresentation.fishTalkFont.MeasureString(tip).Y / 2), IngamePresentation.textScaleFactor, SpriteEffects.None, 0);
                        if (tip2 != "")
                            spriteBatch.DrawString(IngamePresentation.fishTalkFont, tip2, twoDPos + new Vector2(0, IngamePresentation.fishTalkFont.MeasureString(name).Y / 2 + 5 + IngamePresentation.fishTalkFont.MeasureString(tip).Y + 5 + IngamePresentation.fishTalkFont.MeasureString(tip2).Y / 2) * IngamePresentation.textScaleFactor, Color.White, 0,
                                new Vector2(IngamePresentation.fishTalkFont.MeasureString(tip2).X / 2, IngamePresentation.fishTalkFont.MeasureString(tip2).Y / 2), IngamePresentation.textScaleFactor, SpriteEffects.None, 0);
                    }
                    if (line != "" && comment != "")
                    {
                        nonLivingObjWasPointedAt = true;
                        somethingPointedAt = true;
                        enemyWasPointedAt = fishWasPointedAt = false;
                    }
                    //else nonLivingObjWasPointedAt = false;
                    if (somethingPointedAt)
                    {
                        spriteBatch.DrawString(statsFont, line, new Vector2(game.Window.ClientBounds.Width / 2, 4 + statsFont.MeasureString(line).Y / 2 * textScaleFactor), Color.Yellow, 0, new Vector2(statsFont.MeasureString(line).X / 2, statsFont.MeasureString(line).Y / 2), textScaleFactor, SpriteEffects.None, 0);
                        comment = wrapLine(comment, commentMaxLength, statsFont, textScaleFactor);
                        tip = wrapLine(tip, commentMaxLength, statsFont, textScaleFactor);
                        Vector2 commentPos = new Vector2(game.Window.ClientBounds.Width / 2, 4 + (statsFont.MeasureString(line).Y + lineSpacing + statsFont.MeasureString(comment).Y / 2) * textScaleFactor);
                        spriteBatch.DrawString(statsFont, comment, commentPos, Color.Red, 0, new Vector2(statsFont.MeasureString(comment).X / 2, statsFont.MeasureString(comment).Y / 2), textScaleFactor, SpriteEffects.None, 0);
                        //Vector2 tipPos = commentPos + new Vector2(0, statsFont.MeasureString(comment).Y / 2 + lineSpacing + statsFont.MeasureString(tip).Y / 2) * textScaleFactor;
                        //spriteBatch.DrawString(statsFont, tip, tipPos, Color.LightCyan, 0, new Vector2(statsFont.MeasureString(tip).X / 2, statsFont.MeasureString(tip).Y / 2), textScaleFactor, SpriteEffects.None, 0);
                        //if (tip2 != "")
                        //{
                        //    Vector2 tip2Pos = tipPos + new Vector2(0, statsFont.MeasureString(tip).Y / 2 + lineSpacing + statsFont.MeasureString(tip2).Y / 2) * textScaleFactor;
                        //    spriteBatch.DrawString(statsFont, tip2, tip2Pos, Color.LightCyan, 0, new Vector2(statsFont.MeasureString(tip2).X / 2, statsFont.MeasureString(tip2).Y / 2), textScaleFactor, SpriteEffects.None, 0);
                        //}
                        prevLine = line;
                        prevComment = comment;
                        prevTip = tip;
                        prevTip2 = tip2;
                    }
                }
            }

            //if nothing is pointed at now, draw the old obj-pointed messages which fade through time
            if (!somethingPointedAt)
            {
                opaqueValue -= (float)(fadeStep * 20 * (PoseidonGame.playTime.TotalMilliseconds - lastFadeChange) / 1000);
                lastFadeChange = PoseidonGame.playTime.TotalMilliseconds;
                if (opaqueValue <= 0) opaqueValue = 0;
                if (nonLivingObjWasPointedAt)
                {
                    spriteBatch.DrawString(statsFont, prevLine, new Vector2(game.Window.ClientBounds.Width / 2, 4 + statsFont.MeasureString(prevLine).Y / 2 * textScaleFactor), Color.Yellow * opaqueValue, 0, new Vector2(statsFont.MeasureString(prevLine).X / 2, statsFont.MeasureString(prevLine).Y / 2), textScaleFactor, SpriteEffects.None, 0);
                    //comment = wrapLine(comment, commentMaxLength, statsFont, textScaleFactor);
                    //tip = wrapLine(tip, commentMaxLength, statsFont, textScaleFactor);
                    Vector2 commentPos = new Vector2(game.Window.ClientBounds.Width / 2, 4 + (statsFont.MeasureString(prevLine).Y + lineSpacing + statsFont.MeasureString(prevComment).Y / 2) * textScaleFactor);
                    spriteBatch.DrawString(statsFont, prevComment, commentPos, Color.Red * opaqueValue, 0, new Vector2(statsFont.MeasureString(prevComment).X / 2, statsFont.MeasureString(prevComment).Y / 2), textScaleFactor, SpriteEffects.None, 0);
                    //Vector2 tipPos = commentPos + new Vector2(0, statsFont.MeasureString(prevComment).Y / 2 + lineSpacing + statsFont.MeasureString(prevTip).Y / 2) * textScaleFactor;
                    //spriteBatch.DrawString(statsFont, prevTip, tipPos, Color.LightCyan * opaqueValue, 0, new Vector2(statsFont.MeasureString(prevTip).X / 2, statsFont.MeasureString(prevTip).Y / 2), textScaleFactor, SpriteEffects.None, 0);
                    //if (prevTip2 != "")
                    //{
                    //    Vector2 tip2Pos = tipPos + new Vector2(0, statsFont.MeasureString(prevTip).Y / 2 + lineSpacing + statsFont.MeasureString(prevTip2).Y / 2) * textScaleFactor;
                    //    spriteBatch.DrawString(statsFont, prevTip2, tip2Pos, Color.LightCyan * opaqueValue, 0, new Vector2(statsFont.MeasureString(prevTip2).X / 2, statsFont.MeasureString(prevTip2).Y / 2), textScaleFactor, SpriteEffects.None, 0);
                    //}
                }
                if (fishWasPointedAt)
                {
                    //IngamePresentation.DrawHealthBar(game, spriteBatch, statsFont, swimmingObjHealth, swimmingObjMaxHealth, 5, swimmingObjName, opaqueValue);
                    swimmingObjName = swimmingObjName.ToUpper();
                    spriteBatch.DrawString(statsFont, swimmingObjName, new Vector2(game.Window.ClientBounds.Width / 2 - statsFont.MeasureString(swimmingObjName).X / 2 * textScaleFactor, 5 - 1), Color.MediumVioletRed * opaqueValue,
                        0, Vector2.Zero, textScaleFactor, SpriteEffects.None, 0);
                    spriteBatch.DrawString(fishTalkFont, fishTalk, new Vector2(game.Window.ClientBounds.Width / 2, 4 + (fishTalkFont.MeasureString(swimmingObjName).Y + fishTalkFont.MeasureString(fishTalk).Y / 2 + lineSpacing) * textScaleFactor), Color.Yellow * opaqueValue, 0, new Vector2(fishTalkFont.MeasureString(fishTalk).X / 2, fishTalkFont.MeasureString(fishTalk).Y / 2), textScaleFactor, SpriteEffects.None, 0);
                }
                //if (enemyWasPointedAt)
                //{
                //    IngamePresentation.DrawHealthBar(game, spriteBatch, statsFont, swimmingObjHealth, swimmingObjMaxHealth, 5, swimmingObjName, opaqueValue);
                //}
            }
            else
            {
                opaqueValue = startingOpaqueValue;
            }
        }
示例#49
0
     public override void Start()
     {
         base.Start();
         enemy = GetComponent<BaseEnemy>();

     }
示例#50
0
	private void BaseEnemy_OnDie(BaseEnemy enemy_)
	{		
		baseEnemyCount--;
		enemy_.OnBeforeDie -= this.BaseEnemy_OnDie;

		if (this.IsFinished)
			this.State = RoomSpawnerState.Finishing;
	}
示例#51
0
    private void BeforeDie(BaseEnemy baseEnemy_)
    {
        this._capsule.enabled = false;
        this._navmeshAgent.velocity = Vector3.zero;

        if (this._navmeshAgent.hasPath)
            this._navmeshAgent.ResetPath();

        if (!IsRagDoll)
        {
            this._animator.SetTrigger(ANIM_DEAD);
			GetComponent<AudioSource> ().PlayOneShot (audio[0]);
        }
        else
        {
            this._animator.enabled = false;
			GetComponent<AudioSource> ().PlayOneShot (audio[0]);
        }

        this._navmeshAgent.enabled = false;
    }
示例#52
0
    void Start()
    {
        mAnimator = GetComponent<Animator>();
        mAudioSource = GetComponent<AudioSource>();
        this.embarrassmentMeter = GameObject.Find("EmbarassmentMeter").GetComponent<EmbarrassmentMeter>();
        playerStats = GameObject.Find("PlayerStats").GetComponent<PlayerStats>();
        this.cooldownTimer = this.allowCooldownTime;

        this.enemyList = GameObject.FindGameObjectsWithTag("Enemy");
        this.enemyScript = this.enemyList[0].GetComponent<BaseEnemy>();
        AlarmSound = (AudioSource)GameObject.Find("AlarmSound").GetComponent<AudioSource>();

        this.playerReskinScript = this.GetComponent<PlayerReskin>();

        ewwManager = GameObject.Find ("EwwManager").GetComponent<EwwManager>();

        this.headsUpDisplayScript = GameObject.Find("HeadsUpDisplay").GetComponent<HeadsUpDisplay>();

        //this.actionButtonE = GameObject.Find("ActionButtonE");
    }
示例#53
0
        public void PrepareEdgeDetect(HydroBot hydroBot, Cursor cursor, Camera gameCamera, Fish[] fish, int fishAmount, BaseEnemy[] enemies, int enemiesAmount, List<Trash> trashes, List<ShipWreck> shipWrecks, List<Factory> factories, ResearchFacility researchFacility, List<TreasureChest> treasureChests, List<Powerpack> powerPacks, List<Resource> resources, GraphicsDevice graphicsDevice, RenderTarget2D normalDepthRenderTargetLow, RenderTarget2D normalDepthRenderTargetHigh)
        {
            graphicsDevice.SetRenderTarget(normalDepthRenderTargetLow);
            graphicsDevice.Clear(Color.Black);
            graphicsDevice.SetRenderTarget(normalDepthRenderTargetHigh);
            graphicsDevice.Clear(Color.Black);

            if (!GameSettings.SpecialEffectsEnabled) return;

            graphicsDevice.SamplerStates[0] = SamplerState.LinearClamp;

            Fish fishPointedAt = CursorManager.MouseOnWhichFish(cursor, gameCamera, fish, fishAmount);
            if (fishPointedAt != null)
            {
                graphicsDevice.SetRenderTarget(normalDepthRenderTargetHigh);
                fishPointedAt.Draw(gameCamera.ViewMatrix, gameCamera.ProjectionMatrix, gameCamera, "NormalDepth");
                edgeDetectionParameters["EdgeColor"].SetValue(new Vector4(0, 1, 0, 1));

            }
            else
            {
                BaseEnemy enemyPointedAt = CursorManager.MouseOnWhichEnemy(cursor, gameCamera, enemies, enemiesAmount);
                if (enemyPointedAt != null)
                {
                    graphicsDevice.SetRenderTarget(normalDepthRenderTargetHigh);
                    enemyPointedAt.Draw(gameCamera.ViewMatrix, gameCamera.ProjectionMatrix, gameCamera, "NormalDepth");
                    edgeDetectionParameters["EdgeColor"].SetValue(new Vector4(1, 0, 0, 1));
                }
                else
                {
                    Powerpack powerPackPointedAt = null, botOnPowerPack = null;
                    CursorManager.MouseOnWhichPowerPack(cursor, gameCamera, powerPacks, ref powerPackPointedAt, ref botOnPowerPack, null);
                    if (powerPackPointedAt != null)
                    {
                        graphicsDevice.SetRenderTarget(normalDepthRenderTargetHigh);
                        powerPackPointedAt.Draw(gameCamera.ViewMatrix, gameCamera.ProjectionMatrix, gameCamera, "NormalDepth");
                        edgeDetectionParameters["EdgeColor"].SetValue(Color.Gold.ToVector4());
                    }
                    else
                    {
                        Resource resourcePackPointedAt = null, botOnResource = null;
                        CursorManager.MouseOnWhichResource(cursor, gameCamera, resources, ref resourcePackPointedAt, ref botOnResource, null);
                        if (resourcePackPointedAt != null)
                        {
                            graphicsDevice.SetRenderTarget(normalDepthRenderTargetHigh);
                            resourcePackPointedAt.Draw(gameCamera.ViewMatrix, gameCamera.ProjectionMatrix, gameCamera, "NormalDepth");
                            edgeDetectionParameters["EdgeColor"].SetValue(Color.Gold.ToVector4());
                        }
                        else
                        {
                            TreasureChest chestPointedAt = CursorManager.MouseOnWhichChest(cursor, gameCamera, treasureChests);
                            if (chestPointedAt != null)
                            {
                                graphicsDevice.SetRenderTarget(normalDepthRenderTargetLow);
                                chestPointedAt.Draw(gameCamera.ViewMatrix, gameCamera.ProjectionMatrix, gameCamera, "NormalDepth");
                                edgeDetectionParameters["EdgeColor"].SetValue(Color.Gold.ToVector4());
                            }
                            Trash trashPointedAt = null, botOnTrash = null;
                            CursorManager.MouseOnWhichTrash(cursor, gameCamera, trashes, ref trashPointedAt, ref botOnTrash, null);
                            if (trashPointedAt != null)
                            {
                                if (trashPointedAt.sinking)
                                    graphicsDevice.SetRenderTarget(normalDepthRenderTargetHigh);
                                else graphicsDevice.SetRenderTarget(normalDepthRenderTargetLow);
                                trashPointedAt.Draw(gameCamera.ViewMatrix, gameCamera.ProjectionMatrix, gameCamera, "NormalDepth");
                                edgeDetectionParameters["EdgeColor"].SetValue(Color.Gold.ToVector4());
                            }
                            else
                            {
                                ShipWreck shipPointedAt = CursorManager.MouseOnWhichShipWreck(cursor, gameCamera, shipWrecks);
                                if (shipPointedAt != null)
                                {
                                    graphicsDevice.SetRenderTarget(normalDepthRenderTargetLow);
                                    shipPointedAt.Draw(gameCamera.ViewMatrix, gameCamera.ProjectionMatrix, gameCamera, "NormalDepth");
                                    edgeDetectionParameters["EdgeColor"].SetValue(Color.Gold.ToVector4());
                                }
                                else
                                {
                                    Factory factoryPointedAt = CursorManager.MouseOnWhichFactory(cursor, gameCamera, factories);
                                    if (factoryPointedAt != null)
                                    {
                                        graphicsDevice.SetRenderTarget(normalDepthRenderTargetLow);
                                        factoryPointedAt.Draw(gameCamera.ViewMatrix, gameCamera.ProjectionMatrix, gameCamera, "NormalDepth");
                                        edgeDetectionParameters["EdgeColor"].SetValue(Color.Gold.ToVector4());
                                    }
                                    else
                                    {
                                        if (CursorManager.MouseOnResearchFacility(cursor, gameCamera, researchFacility))
                                        {
                                            graphicsDevice.SetRenderTarget(normalDepthRenderTargetLow);
                                            researchFacility.Draw(gameCamera.ViewMatrix, gameCamera.ProjectionMatrix, gameCamera, "NormalDepth");
                                            edgeDetectionParameters["EdgeColor"].SetValue(Color.Gold.ToVector4());
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }

            graphicsDevice.SamplerStates[0] = SamplerState.LinearWrap;
        }
示例#54
0
 void Start()
 {
     be = this.GetComponent<BaseEnemy>();
     relocate();
 }
示例#55
0
    /// <summary>
    /// Metodo responsavel por verificar se é necessário explodir e executar a explosao
    /// </summary>
    public virtual void Explode(bool forceExplosion)
    {
        if (_armed && _timeToExplode < Time.time || forceExplosion)
        {
            // Toca o som de explosao

            // Apresenta particulas de explosao
            if (ExplosionParticlePrefab != null)
            {
                GameObject explosionParticle = GameObject.Instantiate(ExplosionParticlePrefab);
                explosionParticle.transform.position = transform.position;
                GameObject.Destroy(explosionParticle, 5f);
            }

            ApplicationModel.Instance.ShakeCamera();

            // Verifica as colisoes
            int _hits = Physics.OverlapSphereNonAlloc(transform.position, ExplosionRadius, _colliders, AffectedLayer);

            if (_hits > 0)
            {
                for (int i = 0; i < _hits; i++)
                {
                    // Recupera os componentes
                    _affectedCharacter = _colliders[i].GetComponent<BaseEnemy>();
                    _affectedRigidBody = _colliders[i].attachedRigidbody;

                    if (_affectedCharacter != null)
                    {
                        // Aplica dano se for personagem
						_affectedCharacter.ApplyDamage(ThrownByCharacter, ENUMERATORS.Combat.DamageType.Melee, ENUMERATORS.Player.PlayerClass.UNDEFINED ,ExplosionDamage);
                    }

                    if (_affectedRigidBody != null)
                    {
                        // Aplica a forca de explosao nos rigidbodys
                        _affectedRigidBody.AddExplosionForce(ExplosionForce, transform.position + Vector3.up * ExplosionYOffSet, ExplosionRadius);
                        _affectedRigidBody.AddForce(Vector3.up * ExplosionForce);
                    }
                }
            }

            ReturnToPool();
        }
    }
示例#56
0
 private void Awake()
 {
     enemy = GetComponent<BaseEnemy>();
     attackTriggerVolume.OnTriggerStayEvent += OnAttackTriggerVolumeStay;
     attackTriggerVolume.OnTriggerExitEvent += OnAttackTriggerVolumeExit;
 }
示例#57
0
    void Start()
    {
        switch (actualEnemy)
        {
            case enemyType.policeman_LVL01:
                enemyManager = new Policeman(10,1,2);
                damageInformation = new Damage(enemyManager.Damage, PlayerModel.DamageTypes.Standard);
                break;

            case enemyType.policeman_LVL02:
                enemyManager = new Policeman(20, 1, 3);
                damageInformation = new Damage(enemyManager.Damage, PlayerModel.DamageTypes.Fire);
                break;

            case enemyType.policeman_LVL03:
                enemyManager = new Policeman(30, 2, 3);
                damageInformation = new Damage(enemyManager.Damage, PlayerModel.DamageTypes.Ice);
                break;

            case enemyType.roboter_LVL01:
                enemyManager = new Robot(50, 3, 5);
                damageInformation = new Damage(enemyManager.Damage, PlayerModel.DamageTypes.Standard);
                break;
        }
    }
示例#58
0
    // Update is called once per frame
    void Update()
    {
        switch (estadoActual) {
            case(state.START):
                //Inicializar todo, poner los sprites de los 3 personajes del party en la scene, y cargar el enemigo.
                //Y al finalizar de todas esas inicializaciones, pasar al estador player, a este estado nunca se vuelve.
            foreach(CharactersBase party in GameController.Instance.jugador.party){
                switch(posicionar){
                case(1):
                    switch(verloquees(party)){
                    case(1):
                        archer.transform.position = posicion1.transform.position;
                        break;
                    case(2):
                        knight.transform.position = posicion1.transform.position;
                        break;
                    case(3):
                        thief.transform.position = posicion1.transform.position;
                        break;
                    case(4):
                        wm.transform.position = posicion1.transform.position;
                        break;
                    case(5):
                        wizard.transform.position = posicion1.transform.position;
                        break;
                    }
                    break;
                case(2):
                    switch(verloquees(party)){
                    case(1):
                        archer.transform.position = posicion2.transform.position;
                        break;
                    case(2):
                        knight.transform.position = posicion2.transform.position;
                        break;
                    case(3):
                        thief.transform.position = posicion2.transform.position;
                        break;
                    case(4):
                        wm.transform.position = posicion2.transform.position;
                        break;
                    case(5):
                        wizard.transform.position = posicion2.transform.position;
                        break;
                    }
                    break;
                case(3):
                    switch(verloquees(party)){
                    case(1):
                        archer.transform.position = posicion3.transform.position;
                        break;
                    case(2):
                        knight.transform.position = posicion3.transform.position;
                        break;
                    case(3):
                        thief.transform.position = posicion3.transform.position;
                        break;
                    case(4):
                        wm.transform.position = posicion3.transform.position;
                        break;
                    case(5):
                        wizard.transform.position = posicion3.transform.position;
                        break;
                    }
                    break;
                }
                posicionar++;
            }
            switch(GameController.Instance.jugador.enemigo){
            case(1):
                enemigoActual = new Bee();
                bee.transform.position = posicionEnemigo.transform.position;
                break;
            case(2):
                enemigoActual = new Dragon();
                dragon.transform.position = posicionEnemigo.transform.position;
                break;
            case(3):
                enemigoActual = new Eye();
                eye.transform.position = posicionEnemigo.transform.position;
                break;
            case(4):
                enemigoActual = new Ogre();
                ogre.transform.position = posicionEnemigo.transform.position;
                break;
            case(5):
                enemigoActual = new Spider();
                spider.transform.position = posicionEnemigo.transform.position;
                break;
            case(6):
                enemigoActual = new Turtle();
                turtle.transform.position = posicionEnemigo.transform.position;
                break;
            }
            estadoActual = state.PLAYER;
            break;

            case(state.PLAYER):
            //Logica de atacar, tomando los botones x(attack1), y(attack2), z(attack3).
            if(attack <=2){
                if(vivo1 && !ataco1 && Input.GetButtonDown("Attack1")){
                    enemigoActual.currentHealth -= (GameController.Instance.jugador.party[0].strength - enemigoActual.armor);
                    ataco1 = true;
                    Debug.Log (enemigoActual.currentHealth);
                    if(enemigoActual.currentHealth <= 0){
                        estadoActual = state.WIN;
                        System.Threading.Thread.Sleep (1500);
                    }
                    attack++;
                    if(attack == 3){
                        ataco1 = false;
                        ataco2 = false;
                        ataco3 = false;
                        estadoActual= state.ENEMY;
                        Debug.Log(estadoActual);
                    }
                }
                if(vivo2 && !ataco2 && Input.GetButtonDown("Attack2")){
                    enemigoActual.currentHealth -= (GameController.Instance.jugador.party[1].strength - enemigoActual.armor);
                    ataco2 = true;
                    Debug.Log (enemigoActual.currentHealth);
                    if(enemigoActual.currentHealth <= 0){
                        estadoActual = state.WIN;
                        System.Threading.Thread.Sleep (1500);
                    }
                    attack++;
                    if(attack == 3){
                        ataco1 = false;
                        ataco2 = false;
                        ataco3 = false;
                        estadoActual= state.ENEMY;
                        Debug.Log(estadoActual);
                    }
                }
                if(vivo3 && !ataco3 && Input.GetButtonDown("Attack3")){
                    enemigoActual.currentHealth -= (GameController.Instance.jugador.party[2].strength - enemigoActual.armor);
                    ataco3 = true;
                    Debug.Log (enemigoActual.currentHealth);
                    if(enemigoActual.currentHealth <= 0){
                        estadoActual = state.WIN;
                        System.Threading.Thread.Sleep (1500);
                    }
                    Debug.Log(enemigoActual.currentHealth);
                    attack++;
                    if(attack == 3){
                        ataco1 = false;
                        ataco2 = false;
                        ataco3 = false;
                        estadoActual= state.ENEMY;
                        Debug.Log(estadoActual);
                    }
                }
            }
            break;

            case(state.ENEMY):
                //Logica de atacar del enemigo (Aleatorio).
            destino = rnd.Next(0, 2);
            GameController.Instance.jugador.party[destino].currentHP -= (enemigoActual.strength -  GameController.Instance.jugador.party[destino].armor);
                if(GameController.Instance.jugador.party[destino].currentHP <= 0){
                    if(destino == 0){
                    vivo1 = false;
                    Console.WriteLine("Ha muerto: ");
                    Debug.Log(GameController.Instance.jugador.party[destino].characterName);
                        if(!vivo1 && !vivo2 && !vivo3)
                        estadoActual = state.LOSE;
                    }
                    if(destino == 1){
                    vivo2 = false;
                    Console.WriteLine("Ha muerto: ");
                    Debug.Log(GameController.Instance.jugador.party[destino].characterName);
                        if(!vivo1 && !vivo2 && !vivo3)
                        estadoActual = state.LOSE;
                    }
                    if(destino == 2){
                    vivo3 = false;
                    Console.WriteLine("Ha muerto: ");
                    Debug.Log(GameController.Instance.jugador.party[destino].characterName);
                        if(!vivo1 && !vivo2 && !vivo3)
                        estadoActual = state.LOSE;
                    }
                }
            Debug.Log(GameController.Instance.jugador.party[destino].characterName);
            Debug.Log(GameController.Instance.jugador.party[destino].currentHP);
            estadoActual = state.PLAYER;

            Debug.Log (estadoActual);
            break;

            case(state.LOSE):
                //Game Over.
                System.Threading.Thread.Sleep (1500);
                Application.Quit();
            break;

            case(state.WIN):
                // Ir a la scene previa y anadir el item del enemigo el inventario del jugador.
            Debug.Log (estadoActual);
            GameController.Instance.jugador.inventario.Add (enemigoActual.drop); // Anadiendo el item del enemigo al inventario.
            cambiar.ChangeSceneTo(2);
            break;

        }
    }