예제 #1
0
    public RPSEnemy InitializeEnemy(Attacks.AtkDefElement elemtype, Vector3 startpos)
    {
        RPSEnemy tempEnemy = null;

        if (ObjectPool.Instance.HasBug(elemtype))
        {
            tempEnemy = ObjectPool.Instance.DepoolBug(elemtype);
            // tempBullet.gameObject.transform.position = startpos;
        }
        else
        {
            switch (elemtype)
            {
            case Attacks.AtkDefElement.Rock:
                tempEnemy = GameObject.Instantiate(rock).GetComponent <RPSEnemy>();
                break;

            case Attacks.AtkDefElement.Paper:
                tempEnemy = GameObject.Instantiate(paper).GetComponent <RPSEnemy>();
                break;

            case Attacks.AtkDefElement.Scissors:
                tempEnemy = GameObject.Instantiate(scissors).GetComponent <RPSEnemy>();
                break;
            }
        }
        tempEnemy.gameObject.transform.position = startpos;
        tempEnemy.gameObject.transform.parent   = BulletParent.transform;

        tempEnemy.gameObject.SetActive(true);
        return(tempEnemy);
    }
예제 #2
0
    public IEnumerator DissolveBug(RPSEnemy e)
    {
        Renderer rend;

        if (attackElement == Attacks.AtkDefElement.Rock)
        {
            rend = e.GetComponent <Renderer>();
        }
        else
        {
            rend = e.transform.Find("Shape").GetComponent <Renderer>();
        }
        rend.material = EnemyManager.Instance.dissolveMat;
        rend.material.SetVector("_EdgeColor1", RPSColors[(int)e.attackElement] * 4f);
        rend.material.SetVector("_Color", RPSColors[(int)e.attackElement] * 1f);
        float timer = 0f;

        while (timer < 2f)
        {
            timer += Time.deltaTime;
            float cutoff = Mathf.Lerp(0, 1, timer / 2f);
            rend.material.SetFloat("_cutoff", cutoff);
            //Debug.Log(timer / 3f);
            yield return(new WaitForSeconds(Time.deltaTime));
        }
        rend.material = EnemyManager.Instance.baseMats[(int)attackElement];
        e.gameObject.SetActive(false);
        ObjectPool.Instance.PoolBug(e.attackElement, e);
    }
예제 #3
0
 public void PoolBug(Attacks.AtkDefElement elemtype, RPSEnemy enemy)
 {
     if (!EnemyPool.ContainsKey(elemtype))
     {
         EnemyPool.Add(elemtype, new Queue <RPSEnemy>());
     }
     EnemyPool[elemtype].Enqueue(enemy);
 }
예제 #4
0
    public void DoDefense(int defenseMode, RPSEnemy source, Attacks.AtkDefElement attackingElement, Attacks.AttackType atkType)
    {
        int XPMult = 2;

        if (defenseMode == 1)      // Good Defense
        {
            XPMult = -1;
            switch (defenseType)
            {
            case DefenseType.Dmg:
                source.hp -= dmgValue * 5;
                break;

            case DefenseType.DrainHP:
                hp        += dmgValue * 3;
                source.hp -= dmgValue * 3;
                break;

            case DefenseType.BolsterAtk:
                if (dmgValue < 20)
                {
                    dmgValue *= 2;
                }
                break;
            }
        }
        else if (defenseMode == 0)
        {
            XPMult = 4;
            switch (defenseType)
            {
            case DefenseType.Dmg:
                hp -= dmgValue * 5;
                break;

            case DefenseType.DrainHP:
                hp        -= dmgValue * 3;
                source.hp += dmgValue * 3;
                break;

            case DefenseType.BolsterAtk:
                if (dmgValue > float.MinValue)
                {
                    dmgValue /= 2;
                }
                break;
            }
        }

        if (source.CompareTag("Player"))
        {
            source.GetComponent <Moveonterrain>().CalculateXPDamage(XPMult, attackingElement, atkType);
        }
        else
        {
            Debug.Log("PAJWO");
        }
    }
예제 #5
0
    public void Initialize()
    {
        rock     = Resources.Load <RPSEnemy>("Prefabs/RockAI");
        paper    = Resources.Load <RPSEnemy>("Prefabs/Paper");
        scissors = Resources.Load <RPSEnemy>("Prefabs/ScissorAI");

        tower  = Resources.Load <EnvironmentObject>("Prefabs/Tower");
        statue = Resources.Load <EnvironmentObject>("Prefabs/Statue");

        melee  = Resources.Load <ParticleSystem>("Particles/Melee");
        ranged = Resources.Load <ParticleSystem>("Particles/Ranged");
        aoe    = Resources.Load <ParticleSystem>("Particles/AoE");
    }
예제 #6
0
 public void BugFinished(RPSEnemy enemy)
 {
     //bool bugKilled = false;
     //enemy.transform.position = enemy.transform.position;
     //bugKilled = enemy.DoKillBug();
     //if(bugKilled)
     if (enemyList.Contains(enemy))
     {
         enemyList.Remove(enemy);
         if (!enemy.gameObject.CompareTag("Special"))
         {
             enemy.KillEnemy();
         }
     }
 }
예제 #7
0
    public void CreateBug(Attacks.AtkDefElement elemtype, Vector3 startPos)
    {
        RPSEnemy e = Factory.Instance.InitializeEnemy(elemtype, startPos);
        Renderer rend;

        if (e.attackElement == Attacks.AtkDefElement.Rock)
        {
            rend = e.GetComponent <Renderer>();
        }
        else
        {
            rend = e.transform.Find("Shape").GetComponent <Renderer>();
        }
        rend.material = baseMats[(int)e.attackElement];
        e.RefreshStats();
        enemyList.Add(e);
    }
예제 #8
0
    private void OnTriggerEnter(Collider other)
    {
        if (other.gameObject.layer == LayerMask.NameToLayer("Enemy"))
        {
            var      enemyScripts = other.transform.GetComponents <RPSEnemy>();
            RPSEnemy enemyScript  = null;
            if (enemyScripts.Length > 0)
            {
                enemyScript = enemyScripts[Random.Range(0, enemyScripts.Length)];
            }
            else
            {
                Debug.Log("POWA");
            }
            if (enemyScript)
            {
                //     Debug.Log(enemyScript.attackElement);
                if (source && source.CompareTag("Player"))
                {
                    var playerScript = source.GetComponent <RPSEnemy>();
                    if (enemyScript.attackElement == (Attacks.AtkDefElement)((int)(attackElement + 1) % 3))
                    {
                        enemyScript.DoDefense(1, playerScript, attackElement, attackType);         //  Debug.Log(source + " Made Bad Attack On " + other);
                    }
                    else if (attackElement == (Attacks.AtkDefElement)((int)(enemyScript.attackElement + 1) % 3))
                    {
                        enemyScript.DoDefense(0, playerScript, attackElement, attackType);        //Debug.Log(source + " Made Good Attack On " + other);
                        enemyScript.DoDamage(playerScript.dmgValue, attackType, attackElement, playerScript.gameObject.GetComponent <Moveonterrain>());
                    }
                    else if (enemyScript.attackElement == attackElement)
                    {
                        enemyScript.DoDamage(playerScript.dmgValue, attackType, attackElement, playerScript.gameObject.GetComponent <Moveonterrain>());     //Debug.Log(source + " Made Neutral Attack On " + other);
                    }
                    ParticlesManager.Instance.CreateParticle(attackType, attackElement, other.transform.position);
                    AudioManager.Instance.CreateAudio(other.transform.position, AudioClipManager.attackClips[1, (int)attackType], other.transform);
                }
            }
        }

        if (other.gameObject.layer == LayerMask.NameToLayer("Player"))
        {
            var playerScript = other.GetComponent <RPSEnemy>();
            var enemyScript  = source.GetComponent <RPSEnemy>();
            if (playerScript.attackElement == (Attacks.AtkDefElement)((int)(attackElement + 1) % 3))
            {
                enemyScript.DoDefense(0, playerScript, attackElement, attackType);         //  Debug.Log(source + " Made Bad Attack On " + other);
            }
            else if (attackElement == (Attacks.AtkDefElement)((int)(playerScript.attackElement + 1) % 3))
            {
                enemyScript.DoDefense(1, playerScript, attackElement, attackType);
                playerScript.DoDamage(enemyScript.dmgValue, attackType, attackElement);
                //Debug.Log(source + " Made Good Attack On " + other);
            }
            else if (playerScript.attackElement == attackElement)
            {
                playerScript.DoDamage(enemyScript.dmgValue, attackType, attackElement);     //Debug.Log(source + " Made Neutral Attack On " + other);
            }
            ParticlesManager.Instance.CreateParticle(attackType, attackElement, other.transform.position);
            AudioManager.Instance.CreateAudio(other.transform.position, AudioClipManager.attackClips[1, (int)attackType], other.transform);
        }

        if (other.gameObject.layer == LayerMask.NameToLayer("LevelUp"))
        {
            if (source && source.CompareTag("Player"))
            {
                var towerScript  = other.GetComponentInParent <Tower>();
                var playerScript = source.GetComponent <Moveonterrain>();
                if (playerScript.XP[(int)attackElement] >= playerScript.XPLevelThreshold[(int)attackElement])
                {
                    if (towerScript.attackElement == (Attacks.AtkDefElement)((int)(attackElement + 1) % 3))
                    {
                        towerScript.PerformLevelUp(playerScript, -1);    //  Debug.Log(source + " Made Bad Attack On " + other);
                    }
                    else if (attackElement == (Attacks.AtkDefElement)((int)(towerScript.attackElement + 1) % 3))
                    {
                        towerScript.PerformLevelUp(playerScript, 1);    //Debug.Log(source + " Made Good Attack On " + other);
                    }
                    else if (towerScript.attackElement == attackElement)
                    {
                        towerScript.PerformLevelUp(playerScript, 0); //Debug.Log(source + " Made Neutral Attack On " + other);
                    }
                }
            }
        }
    }
예제 #9
0
 // Start is called before the first frame update
 void Start()
 {
     enemy      = transform.parent.GetComponent <RPSEnemy>();
     hpflameSet = GetComponent <Renderer>();
 }