//treat 0 as none even though its technically shield.
        private byte GetMutatedAttack(byte oldAttackId, EnemyObject enemy)
        {
            //likely that an attack with no associated animation will soft lock the game
            if (oldAttackId == 0 || oldAttackId == 255)
            {
                return(oldAttackId);
            }
            var doMutation = Agent.Rng.NextDouble();

            if (doMutation > Agent.Probabilities.EnemyAttackMutationRate)
            {
                return(oldAttackId);
            }
            var attackTier = AttackTierList.GetAttackTier(oldAttackId);
            var newTier    = RandomFunctions.GenerateGaussianByte(Agent.Rng, attackTier, 1, (byte)(AttackTierList.TieredAtpIds.Count - 1));
            var changeType = Agent.Rng.NextDouble();
            var oldType    = AttackTierList.GetAttackType(oldAttackId);

            if (oldType == "")
            {
                return(oldAttackId);
            }
            var newType = GetNewType(oldType, Agent.Probabilities.EnemyAttackTypeMutationRate, newTier);

            List <int> attackList = AttackTierList.GetTierList(newType, newTier);

            var attackIndex = Agent.Rng.Next(0, attackList.Count);

            return((byte)attackList[attackIndex]);
        }
 public void MutateEnemyDrops(EnemyObject enemy)
 {
     enemy.DropId    = ItemRandomizer.GetMutatedItemId(enemy.DropId, Agent.Probabilities.EnemyDropMutationRate, Agent.Probabilities.DefaultItemStandardDeviation);
     enemy.DropRate  = RandomFunctions.GenerateGaussianByte(Agent.Rng, enemy.DropRate, Agent.Probabilities.EnemyDropPercentageStandardDeviation, 100);
     enemy.StealId   = ItemRandomizer.GetMutatedItemId(enemy.StealId, Agent.Probabilities.EnemyDropMutationRate, Agent.Probabilities.DefaultItemStandardDeviation);
     enemy.StealRate = RandomFunctions.GenerateGaussianByte(Agent.Rng, enemy.StealRate, Agent.Probabilities.EnemyDropPercentageStandardDeviation, 100);
 }
Exemplo n.º 3
0
    public override void AnimationState()
    {
        switch (animationState)
        {
        case State.Idle:
        {
            EnemyObject.GetComponent <Animation>().Play("Idle");        //accessing the EnemyObject property
            break;
        }

        case State.Running:
        {
            EnemyObject.GetComponent <Animation>().Play("Firing");
            break;
        }

        case State.Death:
        {
            EnemyObject.GetComponent <Animation>().Play("Death");
            isDead = true;
            break;
        }

        default:
        {
            break;
        }
        }
    }
Exemplo n.º 4
0
    /**
     *
     * targetと現存する敵の距離
     * の中で一番近いものを<距離、EnemyObjectを返す。
     * 存在しない場合は EnemyObjectはNULL
     *
     */
    public EnemyObject GetClosestEnemyObjectTo(GameObject target, ref float distance)
    {
        float              minDist         = float.MaxValue;
        EnemyObject        nearestEnemyObj = null;
        List <EnemyObject> enemyList       = GameManager.Instance.crntEnemyDictionary.Values.ToList();

        for (int i = 0; i < enemyList.Count; i++)
        {
            if (enemyList [i] == null)
            {
                continue;
            }

            float comparingDist = Vector3.Distance(target.transform.position, enemyList[i].transform.position);

            if (comparingDist < minDist)
            {
                minDist         = comparingDist;
                nearestEnemyObj = enemyList [i];
            }
        }

        distance = minDist;
        return(nearestEnemyObj);
    }
Exemplo n.º 5
0
    private IEnumerator DestroyEnemy(EnemyObject enemyObject)
    {
        //enemyObject.gameObject.SetActive (false);
        yield return(new WaitForEndOfFrame());

        Destroy(enemyObject.gameObject);
    }
Exemplo n.º 6
0
    // Start is called before the first frame update
    void Start()
    {
        PlayerObject playerObj = new PlayerObject();

        playerObj.id          = 1;
        playerObj.displayName = "Robot";
        playerObj.position    = Vector3.zero;
        activeList.Add(playerObj);

        EnemyObject enemyMelee = new EnemyObject();

        enemyMelee.id          = 0;
        enemyMelee.displayName = "MeleeBot";
        enemyMelee.position    = new Vector3(-5f, 0f, 0f);
        activeList.Add(enemyMelee);

        EnemyObject enemyRanged = new EnemyObject();

        enemyRanged.id          = 1;
        enemyRanged.displayName = "RangedBot";
        enemyRanged.position    = new Vector3(0f, -10f, 0f);
        activeList.Add(enemyRanged);

        CreateFromData();
    }
Exemplo n.º 7
0
    // Start is called before the first frame update
    void Start()
    {
        PlayerObject playerObj = new PlayerObject();

        playerObj.id          = 1;
        playerObj.displayName = "Robot";
        playerObj.position    = Vector3.zero;
        activeList.Add(playerObj);

        EnemyObject enemyMelee = new EnemyObject();

        enemyMelee.id          = 0;
        enemyMelee.displayName = "MeleeBot";
        enemyMelee.position    = new Vector3(-5f, 0f, 0f);
        activeList.Add(enemyMelee);

        EnemyObject enemyRanged = new EnemyObject();

        enemyRanged.id          = 1;
        enemyRanged.displayName = "RangedBot";
        enemyRanged.position    = new Vector3(0f, -10f, 0f);
        activeList.Add(enemyRanged);

        CreateFromData();

        UIManager.Instance.SetupListeners(activeList);

        //myAction = new Action<Vector3>(playerObj.MoveTo);
        //myAction += new Action<Vector3>(enemyMelee.MoveTo);
        //myAction += new Action<Vector3>(enemyRanged.MoveTo);

        //myAction(new Vector3(0f, 5f, 3f));
    }
Exemplo n.º 8
0
 // Update is called once per frame
 void Update()
 {
     if (boss != null)
     {
         if (hpBarText != null)
         {
             hpBarImage.fillAmount = boss.hitpoints / hitPointsAtFull;
             hpBarText.text        = boss.hitpoints + "/" + hitPointsAtFull;
             if (lastHitPoints > boss.hitpoints)
             {
                 mAnimator.Play("HpBarFlash", -1, 0);
             }
         }
         lastHitPoints = boss.hitpoints;
         if (boss.hitpoints == 0)
         {
             hpBarText.text = "REKT";
         }
     }
     else
     {
         if (GameManager.infinityBoss != null)
         {
             boss            = GameManager.infinityBoss;
             hitPointsAtFull = boss.hitpoints;
             lastHitPoints   = hitPointsAtFull;
         }
         else if (lastHitPoints != 0)
         {
             lastHitPoints         = 0;
             hpBarImage.fillAmount = 0;
             hpBarText.text        = "REKT";
         }
     }
 }
 private void ScaleDownEnemy(EnemyObject enemy, int newTier, int oldTier)
 {
     for (var i = oldTier - 1; i >= newTier; i--)
     {
         var scale = 1 - EnemyTierList.TierScales[i];
         ScaleEnemyOneStep(enemy, scale);
     }
 }
Exemplo n.º 10
0
    public static void spawnEnemies(float gameTime)
    {
        //TODO - spawn enemies based off enemy configureation
        EnemyObject enemy = new EnemyObject();

        //TODO - regiester enemies in GameManager
        GameManager.enemies.Add(enemy);
    }
Exemplo n.º 11
0
 void Start()
 {
     if (!spitBall)
     {
         Debug.LogError("Spit ball prefab null");
     }
     enemy = GetComponent <EnemyObject>();
 }
Exemplo n.º 12
0
    public void EnemySpawning(EnemyObject enemyObject, DayNightCycle dayNightCycle)
    {
        //Spawns an enemy around a 360 degrees angle around the player
        var spawnedEnemy = Instantiate(enemy, target.position + Quaternion.Euler(0, 0, Random.Range(0, 360)) * new Vector3(20, 0, 0), Quaternion.identity);

        //Sets up the scriptable object
        enemyObject.SetUp(spawnedEnemy.GetComponent <EnemyMovement>(), spawnedEnemy.GetComponent <EnemyHealth>(), target, backgroundTilemap, spawnedEnemy, spawnedEnemy.GetComponentInChildren <EnemyAttack>(), dayNightCycle);
    }
Exemplo n.º 13
0
 public void Setup(EnemyObject enemy)
 {
     _baseEnemy = enemy;
     enemy.ParseAttackPattern();
     _currentHealth = enemy.MaxHealth;
     _hurtThisBeat  = false;
     OnEnemySpawned?.Invoke();
 }
Exemplo n.º 14
0
 //Low mutation rate for enemy elemental attributes
 private void MutateEnemyElementalAttributes(EnemyObject enemy)
 {
     enemy.RawAttackElement = ElementRandomizer.MutateElementalAttribute(enemy.RawAttackElement);
     enemy.RawWeakness      = ElementRandomizer.MutateElementalAttribute(enemy.RawWeakness);
     enemy.RawResistance    = ElementRandomizer.MutateElementalAttribute(enemy.RawResistance);
     enemy.RawAbsorb        = ElementRandomizer.MutateElementalAttribute(enemy.RawAbsorb);
     enemy.RawImmunity      = ElementRandomizer.MutateElementalAttribute(enemy.RawImmunity);
 }
Exemplo n.º 15
0
 private void ScaleUpEnemy(EnemyObject enemy, int oldTier, int newTier)
 {
     for (var i = oldTier; i < newTier; i++)
     {
         var scale = GetInvertedScale(EnemyTierList.TierScales[i]);
         ScaleEnemyOneStep(enemy, scale);
     }
 }
Exemplo n.º 16
0
    public void GenerateEnemyList(int waveIndex)
    {
        this.currentWaveIndex = waveIndex;

        StageInfoContainer stageInfo = GameManager.Instance.gameState.GetCurrentStage();
        WaveInfoContainer  waveInfo  = stageInfo.GetWaveInfo(this.currentWaveIndex);

        List <JobActionsList> enemyList = waveInfo.GetEnemyList();

//        float mult = stageInfo.GetDifficultyMult();
        BattleType battleType = stageInfo.GetBattleType();

        for (int i = 0; i < enemyList.Count; i++)
        {
            JobActionsList jobList = enemyList[i];
            string         name    = jobList.prefab.Name + " (" + GetTargetNameFromIndex(i) + ")";
            int            index   = i;

            Enemy enemy = new Enemy();
            enemy.Initialize(jobList, name);
            EnemyObject instantiatedEnemy = enemy.InstantiateFromJob <EnemyObject>(jobList, name, index);

            // Apply stat adjustments based on difficulty

            PlayerStats stats = instantiatedEnemy.stats;

            /*
             * foreach(Stat stat in System.Enum.GetValues(typeof(Stat))) {
             *  stats.ModifyStat(stat, (int) (stats.GetStat(stat) * mult));
             * }
             */
            int level = waveInfo.GetWaveInfo().averageLevel;

            if (battleType == BattleType.HARD_BATTLE)
            {
                level += 3;
            }
            else if (battleType == BattleType.EASY_BATTLE)
            {
                level -= 1;
            }
            else if (battleType == BattleType.BOSS)
            {
                // level += 10; // Should be done from inspector side
            }

            stats.ApplyStatsBasedOnLevel(level);

            // TODO: Some sort of entrance animation

            instantiatedEnemy.SetSortingOrder(i);
            FighterSlot slot = enemySlots[i];
            slot.InitializePosition(instantiatedEnemy);

            GameManager.Instance.gameState.enemyParty.SetFighter(i, enemy);
        }
    }
Exemplo n.º 17
0
    /// <summary>
    /// Helper method for creating and spawning a enemy.
    /// </summary>
    /// <param name="enemyObject">The scriptable object describing the enemy.</param>
    /// <param name="position">The position to where the enemy should be spawned to.</param>
    /// <param name="quaternion">The rotation of the enemy.</param>
    /// <returns>The spawned enemy.</returns>
    public static Enemy InstantiateAndSpawn(EnemyObject enemyObject, Rect roomBorder, Vector3 position, Quaternion quaternion)
    {
        GameObject gameObject = Instantiate(enemyObject.Prefab, position, quaternion);
        Enemy      enemy      = gameObject.GetComponent <Enemy>();

        enemy.Set(enemyObject, roomBorder);
        NetworkServer.Spawn(gameObject);
        return(enemy);
    }
Exemplo n.º 18
0
    void SetEnemyParameter(GameObject enemy, EnemyObject enemyObject, int stageCount)
    {
        Unit unit = enemy.GetComponent <Unit>();

        unit.Life       = enemyObject.baseLife + enemyObject.levelPerLife * stageCount;
        unit.Damage     = enemyObject.baseDamage + enemyObject.levelPerDamage * stageCount;
        unit.range      = enemyObject.attackRange;
        unit.weaponType = enemyObject.weaponType;
    }
Exemplo n.º 19
0
    private void OnTriggerEnter2D(Collider2D coll)
    {
        EnemyObject obj = coll.transform.root.GetComponent <EnemyObject>();

        if (obj != null)
        {
            obj.TakeDamage(damageValue, damageType);
        }
        Destroy(gameObject);
    }
    protected override FollowerEnemySubEntity CreateSubEntity(EnemyObject e, int row, int col, out bool success)
    {
        SingleTileEntityObject subentityGameObject = new GameObject().AddComponent <SingleTileEntityObject>();

        subentityGameObject.name             = string.Format("FollowerEnemy[r={0}, c={1}]", row, col);;
        subentityGameObject.spawnRow         = row;
        subentityGameObject.spawnCol         = col;
        subentityGameObject.transform.parent = e.transform;
        return(new FollowerEnemySubEntity(subentityGameObject, this, out success));
    }
Exemplo n.º 21
0
    void Start()
    {
        myAudioSource = GetComponent <AudioSource>();
        enemyObject   = FindObjectOfType <EnemyObject>();
        AddNonTriggerBoxCollider();
        Pathfinder pathfinder = FindObjectOfType <Pathfinder>();
        var        path       = pathfinder.GetPath();

        StartCoroutine(FollowPath(path));
    }
Exemplo n.º 22
0
    private void OnTriggerEnter(Collider other)
    {
        if (other.tag == "BottomPlayer" || other.tag == "Player")
        {
            other.GetComponent <PlayerController>().Death();

            EnemyObject.GameOver(other);
        }
        else if (other.tag == "UpPlayer")
        {
            PlayerController.j = 0;
        }
    }
Exemplo n.º 23
0
 public void CollisionDetected(EnemyObject enemyObject)
 {
     if (pkt_zycia <= 0)
     {
         KillEnemy();
     }
     else
     {
         pkt_zycia--;
         hitParticlePrefab.Play();
         myAudioSource.PlayOneShot(enemyHitSFX);
     }
 }
Exemplo n.º 24
0
 private static void ScaleEnemyOneStep(EnemyObject enemy, double scale)
 {
     enemy.Hp  = (ushort)Math.Min(enemy.Hp * scale, ushort.MaxValue);
     enemy.Atp = (ushort)Math.Min(enemy.Atp * scale, 999);
     //TODO: this is too messed up most likely, since SOR doesn't really scale well
     enemy.Sor   = (ushort)Math.Min(enemy.Sor * scale, 999);
     enemy.Dfp   = (ushort)Math.Min(enemy.Dfp * scale, 999);
     enemy.Mgr   = (ushort)Math.Min(enemy.Mgr * scale, 999);
     enemy.Res   = (ushort)Math.Min(enemy.Res * scale, 999);
     enemy.Pry   = (ushort)Math.Min(enemy.Pry * scale, 99);
     enemy.Gella = (ushort)Math.Min(enemy.Gella * scale, ushort.MaxValue);
     enemy.Xp    = (ushort)Math.Min(enemy.Xp * scale, ushort.MaxValue);
 }
Exemplo n.º 25
0
 //Simple Gaussian variance for base stats
 private void RandomizeEnemyStats(EnemyObject enemy)
 {
     enemy.Hp    = RandomFunctions.GenerateGaussianShort(Agent.Rng, enemy.Hp, enemy.Hp / Agent.Probabilities.EnemyStatStandardDivisor);
     enemy.Mp    = RandomFunctions.GenerateGaussianShort(Agent.Rng, enemy.Mp, enemy.Mp / Agent.Probabilities.EnemyStatStandardDivisor);
     enemy.Atp   = RandomFunctions.GenerateGaussianShort(Agent.Rng, enemy.Atp, enemy.Atp / Agent.Probabilities.EnemyStatStandardDivisor);
     enemy.Sor   = RandomFunctions.GenerateGaussianShort(Agent.Rng, enemy.Sor, enemy.Sor / Agent.Probabilities.EnemyStatStandardDivisor);
     enemy.Dfp   = RandomFunctions.GenerateGaussianShort(Agent.Rng, enemy.Dfp, enemy.Dfp / Agent.Probabilities.EnemyStatStandardDivisor);
     enemy.Mgr   = RandomFunctions.GenerateGaussianShort(Agent.Rng, enemy.Mgr, enemy.Mgr / Agent.Probabilities.EnemyStatStandardDivisor);
     enemy.Res   = RandomFunctions.GenerateGaussianShort(Agent.Rng, enemy.Res, enemy.Res / Agent.Probabilities.EnemyStatStandardDivisor);
     enemy.Pry   = RandomFunctions.GenerateGaussianShort(Agent.Rng, enemy.Pry, enemy.Pry / Agent.Probabilities.EnemyStatStandardDivisor);
     enemy.Gella = RandomFunctions.GenerateGaussianShort(Agent.Rng, enemy.Gella, enemy.Gella / Agent.Probabilities.EnemyStatStandardDivisor);
     enemy.Xp    = RandomFunctions.GenerateGaussianShort(Agent.Rng, enemy.Xp, enemy.Xp / Agent.Probabilities.EnemyStatStandardDivisor);
 }
Exemplo n.º 26
0
 // Use this for initialization
 void Start()
 {
     Collider2D[] AreaTargets = Physics2D.OverlapCircleAll(transform.position, 5f);
     Ability.DebugDrawRadius(transform.position, 5f, Color.green, 1f);
     foreach (Collider2D coll in AreaTargets)
     {
         EnemyObject obj = coll.transform.root.GetComponent <EnemyObject>();
         if (obj != null)
         {
             obj.SetInsane();
         }
     }
     Destroy(gameObject);
 }
Exemplo n.º 27
0
 // Use this for initialization
 void Start()
 {
     Ability.DebugDrawRadius(transform.position, Radius, Color.blue, Duration);
     Collider2D[] tars = Physics2D.OverlapCircleAll(transform.position, Radius);
     foreach (Collider2D tar in tars)
     {
         EnemyObject obj = tar.transform.root.GetComponent <EnemyObject>();
         if (obj != null)
         {
             obj.DampenAttributes(Duration, DampenAmount, AttributeType.ATTACKMULT);
         }
     }
     Destroy(gameObject, Duration);
 }
Exemplo n.º 28
0
 private void RebalanceBoss(EnemyObject enemy)
 {
     if (!RebalanceTiers.Contains(EnemyTierList.GetBossTier(enemy.Id)))
     {
         return;
     }
     enemy.Hp  = (ushort)Math.Min(enemy.Hp * Agent.Probabilities.RebalanceScale, ushort.MaxValue);
     enemy.Atp = (ushort)Math.Min(enemy.Atp * Agent.Probabilities.RebalanceScale, 999);
     enemy.Sor = (ushort)Math.Min(enemy.Sor * Agent.Probabilities.RebalanceScale, 999);
     enemy.Dfp = (ushort)Math.Min(enemy.Dfp * Agent.Probabilities.RebalanceScale, 999);
     enemy.Mgr = (ushort)Math.Min(enemy.Mgr * Agent.Probabilities.RebalanceScale, 999);
     enemy.Res = (ushort)Math.Min(enemy.Res * Agent.Probabilities.RebalanceScale, 999);
     enemy.Pry = (ushort)Math.Min(enemy.Pry * Agent.Probabilities.RebalanceScale, 99);
 }
Exemplo n.º 29
0
 public override void PrimaryAttack(Vector2 pos)
 {
     Collider2D[] hits = Physics2D.OverlapCircleAll(Player_Accessor_Script.DetailsScript.transform.position, 1.5f);
     for (int i = 0; i < hits.Length; i++)
     {
         if (Vector3.Dot((hits[i].transform.position - Player_Accessor_Script.DetailsScript.transform.position).normalized, Camera_Controller_Script.CalculateVectorFromPlayerToMouse()) > .7)
         {
             EnemyObject obj = hits[i].GetComponent <EnemyObject>();
             if (obj != null)
             {
                 obj.TakeDamage(3f, ElementalResistances.PHYSICAL);
             }
         }
     }
 }
Exemplo n.º 30
0
 private bool EnemyHasMagicAttack(EnemyObject enemy)
 {
     if (AttackTierList.GetAttackType(enemy.Attack1Id).Equals(SorType) ||
         AttackTierList.GetAttackType(enemy.Attack1Id).Equals(SorType) ||
         AttackTierList.GetAttackType(enemy.Attack2Id).Equals(SorType) ||
         AttackTierList.GetAttackType(enemy.Attack3Id).Equals(SorType) ||
         AttackTierList.GetAttackType(enemy.Attack4Id).Equals(SorType) ||
         AttackTierList.GetAttackType(enemy.Attack5Id).Equals(SorType) ||
         AttackTierList.GetAttackType(enemy.Attack6Id).Equals(SorType) ||
         AttackTierList.GetAttackType(enemy.Attack7Id).Equals(SorType))
     {
         return(true);
     }
     return(false);
 }