コード例 #1
0
ファイル: WaspGenerator.cs プロジェクト: BorzaAndrei/BasicRPG
    private void SpawnWasps(int type)
    {
        IEnemy wasp = new WaspEnemy();

        wasp = wasp.CreateEnemy();


        if (type % 2 == 0)
        {
            SlowStrongWaspEnemy slowStrongWasp = new SlowStrongWaspEnemy(wasp);
            wasp = slowStrongWasp.CreateEnemy();
        }
        else
        {
            FastWeakWaspEnemy fastWeakWasp = new FastWeakWaspEnemy(wasp);
            wasp = fastWeakWasp.CreateEnemy();
        }

        if (wasp is WaspEnemy)
        {
            WaspEnemy completeWasp = (WaspEnemy)wasp;
            waspGameObject.GetComponent <EnemyScript>().damagePower   = completeWasp.attackPower;
            waspGameObject.GetComponent <SimpleMovementC>().moveSpeed = completeWasp.moveSpeed;
            Instantiate(waspGameObject);
        }
    }
コード例 #2
0
ファイル: EnemyFactory.cs プロジェクト: BorzaAndrei/BasicRPG
    public static IEnemy GetEnemy(string enemyType)
    {
        IEnemy enemy = null;

        if (enemyType.Equals("SlowStrongWasp"))
        {
            if (enemyMap.TryGetValue("SlowStrongWasp", out enemy))
            {
                Debug.Log("Returned the SlowStrongWasp!");
            }
            else
            {
                Debug.Log("Created first SlowStrongWasp!");
                enemy = new WaspEnemy();
                enemy = enemy.CreateEnemy();
                enemy = new SlowStrongWaspEnemy(enemy);
                enemy = enemy.CreateEnemy();
                enemyMap.Add("SlowStrongWasp", enemy);
            }
        }
        else if (enemyType.Equals("FastWeakWasp"))
        {
            if (enemyMap.TryGetValue("FastWeakWasp", out enemy))
            {
                Debug.Log("Returned another FastWeakWasp!");
            }
            else
            {
                Debug.Log("Created first FastWeakWasp!");
                enemy = new WaspEnemy();
                enemy = enemy.CreateEnemy();
                enemy = new FastWeakWaspEnemy(enemy);
                enemy = enemy.CreateEnemy();
                enemyMap.Add("FastWeakWasp", enemy);
            }
        }

        return(enemy);
    }