示例#1
0
    private void InitialMeteorAndStarSpawn()
    {
        for (int i = 0; i < MeteorCount; i++)
        {
            int        meteorKind       = Random.Range(0, MeteorPrefabArray.Length);
            GameObject selectedMeteor   = MeteorPrefabArray[meteorKind];
            BasicMove  meteorMoveScript = selectedMeteor.GetComponent <BasicMove>();

            Vector2 meteorPos =
                new Vector2(Random.Range(meteorMoveScript.HorizontalLimits[0], meteorMoveScript.HorizontalLimits[1]),
                            Random.Range(meteorMoveScript.VerticalLimits[0], meteorMoveScript.VerticalLimits[1]));
            GameObject instantiatedMeteor = Instantiate(selectedMeteor, meteorPos, Quaternion.identity);
            instantiatedMeteor.GetComponent <SpriteRenderer>().color =
                Random.ColorHSV(0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.3f, 0.3f);
        }

        for (int i = 0; i < StarCount; i++)
        {
            int        starKind       = Random.Range(0, StarPrefabArray.Length);
            GameObject selectedStar   = StarPrefabArray[starKind];
            BasicMove  starMoveScript = selectedStar.GetComponent <BasicMove>();

            Vector2 starPos =
                new Vector2(Random.Range(starMoveScript.HorizontalLimits[0], starMoveScript.HorizontalLimits[1]),
                            Random.Range(starMoveScript.VerticalLimits[0], starMoveScript.VerticalLimits[1]));
            GameObject instantiatedStar = Instantiate(selectedStar, starPos, Quaternion.identity);
            instantiatedStar.GetComponent <SpriteRenderer>().color =
                Random.ColorHSV(0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.3f, 0.3f);
        }
    }
示例#2
0
    private void SpawnNewPowerup(bool isPositive)
    {
        float randomIntervalCoef = Random.Range(PowerupSpawnBaseInterval, PowerupSpawnBaseInterval * 2);

        GameObject[] powerupPrefabArray;
        if (isPositive)
        {
            _posPowerupSpawnInterval = randomIntervalCoef * _difficultyManagerScript.GetDifficultyMultiplier(DifficultyParameter.DpPosPowerupSpawnRateDecrease);
            powerupPrefabArray       = PosPowerupPrefabArray;
        }
        else
        {
            _negPowerupSpawnInterval = randomIntervalCoef / _difficultyManagerScript.GetDifficultyMultiplier(DifficultyParameter.DpNegPowerupSpawnRateIncrease);
            powerupPrefabArray       = NegPowerupPrefabArray;
        }

        List <int> occurenceList = new List <int>();
        int        powerupCount  = powerupPrefabArray.Length;

        for (int i = 0; i < powerupCount; ++i)
        {
            int powerupOccurence = powerupPrefabArray[i].GetComponent <Powerup>().PowerupOccurence;
            for (int j = 0; j < powerupOccurence; ++j)
            {
                occurenceList.Add(i);
            }
        }

        int        powerupIndex      = Random.Range(0, occurenceList.Count);
        GameObject selectedPowerup   = powerupPrefabArray[occurenceList[powerupIndex]];
        BasicMove  powerupMoveScript = selectedPowerup.GetComponent <BasicMove>();
        Vector3    powerupPos        = new Vector2(powerupMoveScript.HorizontalLimits[1], Random.Range(powerupMoveScript.VerticalLimits[0], powerupMoveScript.VerticalLimits[1]));

        Instantiate(selectedPowerup, powerupPos, Quaternion.identity);
    }
示例#3
0
 public MoveInfo(BasicMove m, int seqNum, double seqTime, string mk = null)
 {
     move           = m;
     sequenceNumber = seqNum;
     sequenceTime   = seqTime;
     moveKey        = mk;
 }
示例#4
0
 //called before Start, great for referances
 void Awake()
 {
     Paracamera     = Camera.main.transform;
     rb             = player.GetComponent <Rigidbody2D>();
     playerMovement = player.GetComponent <BasicMove>();
     //Debug.Log(playerMovement.moveSpeed);
 }
示例#5
0
 public void ExecuteMove(BasicMove move)
 {
     if (!state.inCombo)
     {
         state.StartCombo();
     }
     state.AddToCombo(move);
 }
示例#6
0
 public virtual void SpawnBullet(GameObject bulletPrefab, float bulletSpeed, BasicMove player, float angle)
 {
     Quaternion dir = Quaternion.Euler(0, 0, angle);
     GameObject bullet = Instantiate(bulletPrefab, player.transform.position + dir * new Vector3(Bullet.bulletSpawnDistance, 0, 0), Quaternion.identity) as GameObject;
     bullet.rigidbody.velocity = dir * new Vector3(bulletSpeed, 0, 0);
     bullet.GetComponent<Bullet>().damage = Damage;
     bullet.GetComponent<Bullet>().owner = player.m_player;
     Physics.IgnoreCollision(bullet.collider, player.collider);
 }
示例#7
0
 public void Initialize(Player playerScript, DifficultyManager difficultyManagerScript, BasicMove basicMoveScript,
                        Vector2 initialMoveDir, EnemyWave assignedWave = null)
 {
     _playerScript            = playerScript;
     _difficultyManagerScript = difficultyManagerScript;
     SetNextFiringInterval();
     _basicMoveScript   = basicMoveScript;
     _assignedEnemyWave = assignedWave;
     InitialMoveDir     = initialMoveDir;
     SetMoveDir(initialMoveDir);
 }
示例#8
0
    public override bool Fire(BasicMove player, float angle)
    {
        if(m_magazine[0] == BulletState.Live && m_boltState == BoltState.Closed){
            AudioManager.PlaySFX(m_gunsfx);
            m_magazine[0] = BulletState.Fired;

            SpawnBullet(m_bulletPrefab, m_bulletSpeed, player, angle);

            return true;
        }
        return false;
    }
示例#9
0
        // Move execution.
        public override bool Execute(List <Cell> targets, Map map)
        {
            // If no target.
            if (targets == null)
            {
                return(false);
            }

            // If more than one target.
            if (targets.Count != 1)
            {
                return(false);
            }

            Cell cell = targets[0];

            // If no executer or cell to move to.
            if (Executer == null || cell == null)
            {
                return(false);
            }

            Route route = null;

            // If cell is not in range.
            if (!InRange(cell.Position, map, ref route))
            {
                return(false);
            }

            // If there is no route to move.
            if (route == null)
            {
                return(false);
            }

            BasicUnit unit = Executer as BasicUnit;;

            for (int i = 1; i < route.Length + 1; ++i)
            {
                if (unit.IsAlive)
                {
                    BasicMove.Execute(route.Cells[i], map);
                }
                else
                {
                    break;
                }
            }

            return(true);
        }
示例#10
0
    public override bool Fire(BasicMove player, float angle)
    {
        if(m_chamber == BulletState.Live && m_slideState == SlideState.Forward){
            AudioManager.PlaySFX(m_gunsfx);
            m_chamber = BulletState.Fired;

            for(int i = 0; i < m_pelletCount; i++){
                SpawnBullet(m_bulletPrefab, m_bulletSpeed, player, angle -m_pelletSpread/2 + m_pelletSpread * i / (m_pelletCount-1));
            }
            return true;
        }
        return false;
    }
示例#11
0
    public void AddToCombo(BasicMove move)
    {
        MoveInfo m = new MoveInfo(move, currentCombo.Count + 1, elapsedComboTime);

        currentCombo.Add(m);
        if (OnStateChanged != null)
        {
            OnStateChanged();
        }

        if (inCombo)
        {
            CheckCombo(currentCombo);
        }
    }
示例#12
0
    public override bool Fire(BasicMove player, float angle)
    {
        if(state != CylinderState.Closed){
            return false;
        }
        if(chambers[currentChamber] == BulletState.Live){
            AudioManager.PlaySFX(gunsfx);
            chambers[currentChamber] = BulletState.Fired;
            NextChamber();

            SpawnBullet(bulletPrefab, bulletSpeed, player, angle);

            return true;
        }
        else{
            NextChamber();
            return false;
        }
    }
示例#13
0
    static IEnumerator PlayerDie()
    {
        // play sound
        RPGSounds.Instance.PlayOneShot(RPGSounds.Instance.playerDieClip);
        // get player:
        GameObject player = GameObject.FindWithTag("Player");
        BasicMove  move   = player.GetComponent <BasicMove>();

        move.enabled = false;           // turn off user control
        CharacterKnockback knock = player.GetComponent <CharacterKnockback>();

        knock.enabled = false;                                                               // turn off knockback too
        player.GetComponent <Animation>().CrossFade("Death");
        yield return(new WaitForSeconds(player.GetComponent <Animation>()["Death"].length)); // wait for death

        // run a transition
        Transition.FadeIn(instance.loseTex, 1);
        yield return(new WaitForSeconds(1.5f));  // 1 second on, then 1/2 way though the wait

        // reset animation:
        player.GetComponent <Animation>().Play("Idle");
        // mid transition: respawn
        RespawnPoint.RespawnPlayer();
        playerHp      = playerMaxHp;
        move.enabled  = true;           // turn on user control
        knock.enabled = true;           // turn on knockback too

        /*
         * see http://unitygems.com/coroutines/
         * http://www.blog.silentkraken.com/2010/01/23/coroutines-in-unity3d-c-version/
         * http://www.altdevblogaday.com/2011/07/07/unity3d-coroutines-in-detail/
         * IEnumerator Die()
         * {
         * //Wait for the die animation to be 50% complete
         * yield return StartCoroutine(WaitForAnimation("die",0.5f, true));
         * //Drop the enemies on dying pickup
         * DropPickupItem();
         * //Wait for the animation to complete
         * yield return StartCoroutine(WaitForAnimation("die",1f, false));
         * Destroy(gameObject);
         *
         * }*/
    }
示例#14
0
    private void SpawnTutorialPowerup(TutorialPowerupItem tutorialPowerupItem)
    {
        GameObject selectedPowerup;
        int        powerupIndex = (int)tutorialPowerupItem.TypeOfPowerup;

        if (powerupIndex >= PosPowerupPrefabArray.Length)
        {
            powerupIndex   -= PosPowerupPrefabArray.Length;
            selectedPowerup = NegPowerupPrefabArray[powerupIndex];
        }
        else
        {
            selectedPowerup = PosPowerupPrefabArray[powerupIndex];
        }
        BasicMove  powerupMoveScript   = selectedPowerup.GetComponent <BasicMove>();
        Vector3    powerupPos          = new Vector2(powerupMoveScript.HorizontalLimits[1], (powerupMoveScript.VerticalLimits[0] + powerupMoveScript.VerticalLimits[1]) * 0.5f);
        GameObject instantiatedPowerup = Instantiate(selectedPowerup, powerupPos, Quaternion.identity);

        instantiatedPowerup.GetComponent <BasicMove>().SetMoveDir(Vector2.left);
    }
示例#15
0
 public abstract bool Fire(BasicMove player, float angle);
示例#16
0
    // Update is called once per frame
    void Update()
    {
        if (hp <= 0)
        {
            return;
        }
        if (knock.IsKnocked)
        {
            return;
        }

        taskCounter -= Time.deltaTime;
        if (taskCounter <= 0)
        {
            taskCounter = Random.Range(5.0f, 10.0f);
            if (Random.value < 0.5f)
            {
                current = Task.Wait;
            }
            else
            {
                current     = Task.Patrol;
                patrolPoint = toGuard.transform.position + new Vector3(Random.Range(-patrolDistance, patrolDistance), 0, Random.Range(-patrolDistance, patrolDistance));
            }
        }

        if (chaseTarget != null)
        {
            patrolPoint = chaseTarget.position;
            if (Vector3.Distance(transform.position, chaseTarget.position) < attackRange)
            {
                MoveTowards(patrolPoint, 0);                           // turn to it
                GetComponent <Animation>().CrossFade(attackClip.name); //attack
                // player damaged: (need attackFlag to stop multitrigger)
                AnimationState state = GetComponent <Animation>()[attackClip.name];
                if (state.time > state.length - 0.1f)
                {
                    if (attackFlag == false)
                    {
                        BasicMove bm = chaseTarget.GetComponent <BasicMove>();
                        bm.Injure(10, gameObject);
                    }
                    attackFlag = true;
                }
                else
                {
                    attackFlag = false;
                }
            }
            else
            {
                MoveTowards(patrolPoint, runSpeed);
                GetComponent <Animation>().CrossFade(runClip.name);
            }
        }
        else
        {
            if (current == Task.Wait)
            {
                GetComponent <Animation>().CrossFade(idleClip.name);
            }
            if (current == Task.Patrol)
            {
                MoveTowards(patrolPoint, walkSpeed);
                GetComponent <Animation>().CrossFade(walkClip.name);
            }
        }
    }
示例#17
0
    private void SpawnEnemies(List <WaveEntity> selectedFormationEntities, int[] shipTypes, float minVerticalStartCoord,
                              float maxVerticalStartCoord, float enemyHorizontalDist, float enemyVerticalDist, float maxEnemyHorizontalDist)
    {
        bool    waveManeuvers = false;
        Vector2 maneuveringVector;
        float   maneuveringVerticalLength = 0.0f;

        float selectedVerticalStartCoord = Random.Range(minVerticalStartCoord, maxVerticalStartCoord);
        float diffFromCeiling            = maxVerticalStartCoord - selectedVerticalStartCoord;
        float diffFromFloor = selectedVerticalStartCoord - minVerticalStartCoord;

        float waveManeuveringRoom;

        if (diffFromCeiling > diffFromFloor)
        {
            waveManeuveringRoom = diffFromCeiling;
            maneuveringVector   = Vector2.up * ManeuveringDirectionMoveSpeed;
        }
        else
        {
            waveManeuveringRoom = diffFromFloor;
            maneuveringVector   = Vector2.down * ManeuveringDirectionMoveSpeed;
        }

        if (waveManeuveringRoom > ShipColliderVertSize)
        {
            //20 40 60 80 100 percent chance of a maneuvering wave depending on difficulty coefficient
            float waveManeuveringChangePercentage = (float)(_difficultyManagerScript.DifficultyCoefs[DifficultyParameter.DpWaveManeuveringChance] * 100) /
                                                    GameConstants.MaxDifficulty;

            int doManeuver = Random.Range(0, 100);
            if (doManeuver < waveManeuveringChangePercentage)
            {
                waveManeuvers             = true;
                maneuveringVerticalLength = Random.Range(ShipColliderVertSize, waveManeuveringRoom);
            }
        }

        //VII. Spawn Enemies
        GameObject waveScoreIndicator = Instantiate(WaveScoreIndicatorPrefab);

        waveScoreIndicator.transform.SetParent(CanvasScorePanel.transform, false);

        GameObject lineRendererObject = Instantiate(ShipConnectionPrefab, Vector3.zero, Quaternion.identity);

        EnemyWave curEnemyWave = new EnemyWave(_playerScript, lineRendererObject.GetComponent <LineRenderer>(),
                                               _canvasRectTransform, waveScoreIndicator, _scoreLeftAnchorXPos, _scoreRightAnchorXPos);

        for (int i = 0; i < selectedFormationEntities.Count; i++)
        {
            int        enemyKind         = shipTypes[i];
            GameObject enemyPrefab       = EnemyPrefabArray[enemyKind];
            BasicEnemy enemyPrefabScript = enemyPrefab.GetComponent <BasicEnemy>();

            Vector2 enemyPos;
            if (i > 0)
            {
                Vector2 posDiff = selectedFormationEntities[i].Position - selectedFormationEntities[i - 1].Position;

                int xPosDiff = (int)posDiff.x;
                int yPosDiff = (int)posDiff.y;

                int xIncrement = xPosDiff != 0 ? Math.Sign(xPosDiff) : 0;
                int yIncrement = yPosDiff != 0 ? Math.Sign(yPosDiff) : 0;

                Vector3 previousEnemyPos = curEnemyWave.GetLastEnemyPosition();

                enemyPos = new Vector2(previousEnemyPos.x + xIncrement * enemyHorizontalDist, previousEnemyPos.y + yIncrement * enemyVerticalDist);
            }
            else
            {
                //determining first enemy position
                enemyPos = new Vector2(enemyPrefabScript.HorizontalSpawnCoord + selectedFormationEntities[i].Position.x * maxEnemyHorizontalDist, selectedVerticalStartCoord);
            }

            GameObject enemy = Instantiate(enemyPrefab, enemyPos, Quaternion.identity);
            Assert.IsNotNull(enemy);

            BasicEnemy basicEnemyScript = enemy.GetComponent <BasicEnemy>();
            BasicMove  basicMoveScript  = enemy.GetComponent <BasicMove>();

            curEnemyWave.AddNewEnemy(enemy, basicEnemyScript);
            basicEnemyScript.Initialize(_playerScript, _difficultyManagerScript, basicMoveScript, selectedFormationEntities[i].MoveDir, curEnemyWave);
            basicEnemyScript.SetMoveDir(selectedFormationEntities[i].MoveDir);
        }
        curEnemyWave.FinalizeAfterWaveIsFilled(waveManeuvers, maneuveringVector, maneuveringVerticalLength);
        _enemyWaves.Add(curEnemyWave);
    }
 public ControlledMoveForCharacter(Transform T)
 {
     mov = new BasicMove();// (T);
     mov.StartFields(T);
     oControlado = T.gameObject;
 }
示例#19
0
 public override void SpawnBullet(GameObject bulletPrefab, float bulletSpeed, BasicMove player, float angle)
 {
     //Do nothing
 }
示例#20
0
 public MovesetItem(int level, BasicMove move)
 {
     LearnLevel = level;
     Move       = move;
 }