Ejemplo n.º 1
0
    public void UpgradeCoin()
    {
        currentUpgradeIndex++;
        CoinBody coinBody;

        if (currentCoin == null)
        {
            coinBody = Instantiate(upgradePathPrefabs[currentUpgradeIndex], transform.position, transform.rotation, null);
        }
        else
        {
            coinBody = Instantiate(upgradePathPrefabs[currentUpgradeIndex], currentCoin.transform.position + Vector3.up * 0.1f,
                                   currentCoin.transform.rotation, null);

            currentCoin.Jump(90f);
            coinBody.body.velocity = currentCoin.body.velocity;
            coinBody.health        = currentCoin.health;
        }

        Destroy(coinBody.GetComponent <CoinNPCBehavior>());
        behavior = coinBody.gameObject.AddComponent <CoinPlayerBehavior>();

        behavior.body             = coinBody;
        cameraLookAt.targetLookAt = coinBody.transform;

        if (currentCoin != null)
        {
            Destroy(currentCoin.gameObject);
        }

        currentCoin = coinBody;
    }
Ejemplo n.º 2
0
    IEnumerator PulseCheck()
    {
        while (true)
        {
            livePlayers = FindObjectsOfType <CoinBody>();
            if (livePlayers.Length < expectedLivePlayerCount)
            {
                float totalBias = biases.Sum();

                float selected = Random.Range(0, totalBias);

                int index = -1;

                do
                {
                    index++;
                    selected -= biases[index];
                } while (selected > 0);

                CoinBody       template   = templates[index];
                CoinSpawnPoint spawnPoint = spawnPoints[Random.Range(0, spawnPoints.Count)];

                spawnPoint.Spawn(template);
            }

            yield return(new WaitForSeconds(2.5f));
        }
    }
Ejemplo n.º 3
0
    private void CheckUpdateTarget(CoinBody fighter)
    {
        CoinNPCBehavior npc = fighter.GetComponent <CoinNPCBehavior>();

        if (npc)
        {
            npc.enemy = parent;
        }
    }
Ejemplo n.º 4
0
    private void PollForEnemies()
    {
        enemies = new List <CoinBody>(GameObject.FindObjectsOfType <CoinBody>());
        enemies.Remove(body);
        Shuffle(enemies);

        if (enemies.Count > 0)
        {
            playerEnemy = enemies[0];
        }
    }
Ejemplo n.º 5
0
    public void OnTriggerEnter(Collider collision)
    {
        CoinBody fighter = collision.GetComponent <CoinBody>();

        if (fighter == null)
        {
            fighter = collision.GetComponentInParent <CoinBody>();
        }

        if (fighter != null)
        {
            if (fighter != parent)
            {
                fighter.Hit();
                Destroy(gameObject);

                CheckUpdatePlayer();
                CheckUpdateTarget(fighter);
            }
        }
    }
Ejemplo n.º 6
0
    public IEnumerator DoNPCStuff()
    {
        while (this)
        {
            yield return(new WaitWhile(GameIsPaused));

            if (CoinPlayer.instance == null)
            {
                yield return(null);

                continue;
            }

            // Do aggro check
            if ((isGroupFrenzy || isFrenzy))
            {
                if (enemy == null)
                {
                    enemy = CoinGame.instance.livePlayers[Random.Range(0, CoinGame.instance.livePlayers.Length)];
                }

                if (enemy == controllingBody)
                {
                    enemy = null;
                }
            }

            if (enemy != null)
            {
                yield return(LookAtEnemy(40));

                yield return(Shoot(50));

                if (Random.value > 0.3f)
                {
                    yield return(LookAround(20));

                    yield return(Jump(20));
                }

                enemyCountdown -= 1;
                if (enemyCountdown <= 0)
                {
                    enemy          = null;
                    enemyCountdown = enemyCooldown;
                }
            }

            // Neutral mode
            if (!enemy && !isGroupFrenzy)
            {
                if (Random.value > 0.2f)
                {
                    yield return(LookAround(50));
                }
                else if (Random.value > 0.2f)
                {
                    yield return(CoolDown(20));
                }
                else if (Random.value > 0.5f)
                {
                    yield return(Jump(20));
                }
                else if (Random.value > 0.8f)
                {
                    yield return(Shoot(30));
                }
            }

            yield return(null);
        }
    }
Ejemplo n.º 7
0
    public void Spawn(CoinBody template)
    {
        Rigidbody item = Instantiate(template, transform.position, transform.rotation, null).body;

        item.AddForce(trajectory, ForceMode.VelocityChange);
    }