コード例 #1
0
 private void Start()
 {
     velocity.SetVelocity(
         Angle.FromDegrees(data.angle).GetHeadingVector() * data.speed);
     //UtilHeading2D.HeadingVectorFromDegrees(data.angle) * data.speed);
     SetColor(data.color);
 }
コード例 #2
0
ファイル: EnemyAttack.cs プロジェクト: ByteNybbler/NotTheFace
    private void TimerVolleyFinished(float secondsOverflow)
    {
        VolleyData volley = data.volley;

        float[] angles = UtilSpread.PopulateAngle(volley.spreadAngle,
                                                  data.volley.projectile.angle,
                                                  volley.projectileCount);
        foreach (float a in angles)
        {
            float angle = a;
            if (data.refs.player != null)
            {
                if (volley.aimAtPlayer)
                {
                    Vector3 playerPos = data.refs.player.transform.position;
                    angle += Angle.FromPoint(transform.position, playerPos).GetDegrees();
                    //UtilHeading2D.SignedAngleToPoint(transform.position, playerPos);
                }
            }
            Quaternion           rotation   = Quaternion.AngleAxis(angle, Vector3.forward);
            GameObject           projectile = Instantiate(prefabProjectile, transform.position, rotation);
            EnemyProjectile      proj       = projectile.GetComponent <EnemyProjectile>();
            EnemyProjectile.Data projData   = data.volley.projectile.DeepCopy();
            projData.angle = angle;
            proj.SetData(projData);
            Velocity2D leftMovement = projectile.GetComponent <Velocity2D>();
            leftMovement.SetVelocity(new Vector2(-data.projectileLeftSpeed, 0.0f));
            projectile.GetComponent <TimeScale>().SetData(timeScale);
        }
        data.volley.projectile.angle += data.volleyDirectionDeltaPerShot;
    }
コード例 #3
0
ファイル: Enemy.cs プロジェクト: ByteNybbler/NotTheFace
 public void SetData(Data val)
 {
     oscillatePosition2D.SetData(val.oscData);
     leftMovement.SetVelocity(val.leftMovementData);
     enemyAttack.SetData(val.attackData);
     enemySprite.SetData(val.spriteData);
     enemyHealth.SetData(val.enemyHealthData);
 }
コード例 #4
0
ファイル: BossOrb.cs プロジェクト: ByteNybbler/NotTheFace
    private void LerpFinish()
    {
        lerper.enabled     = false;
        oscillator.enabled = true;

        // Set the orb's velocity.
        float   targetX       = target ? target.position.x : 0.0f;
        float   signDirection = Mathf.Sign(targetX - transform.position.x);
        Vector2 vel           = new Vector2(signDirection * data.horizontalSpeed, 0.0f);

        velocity.SetVelocity(vel);
    }
コード例 #5
0
    public void Kill()
    {
        data.refs.score.Add(data.pointsWhenKilled);
        data.refs.score.PunchedEnemy();
        DropItem();
        ac.PlaySFX(enemyDeathSounds.GetRandomElement());

        GameObject de = Instantiate(deathExplosion, transform.position, Quaternion.identity);
        Velocity2D lm = de.GetComponent <Velocity2D>();

        lm.SetVelocity(leftMovement.GetVelocity());
        de.GetComponent <TimeScale>().SetData(timeScale);

        Destroy(gameObject);
    }
コード例 #6
0
    // Attempt to drop something.
    private void DropItem()
    {
        ItemType it = data.probItem.Roll();

        if (it == ItemType.None)
        {
            return;
        }
        if (it == ItemType.HealthKit)
        {
            GameObject    pup = Instantiate(prefabHealthKit, transform.position, Quaternion.identity);
            ItemHealthKit hk  = pup.GetComponent <ItemHealthKit>();
            hk.SetData(data.healthKit);

            Velocity2D lm = pup.GetComponent <Velocity2D>();
            lm.SetVelocity(leftMovement.GetVelocity());
            pup.GetComponent <TimeScale>().SetData(timeScale);
        }
        else
        {
            // Only drop these powerups if none currently exist.
            if (!data.refs.playerPowerup.GetPowerupExists())
            {
                GameObject powerup = null;
                switch (it)
                {
                case ItemType.BattleAxe:
                    powerup = Instantiate(prefabBattleAxe, transform.position, Quaternion.identity);
                    break;

                case ItemType.MoreArms:
                    powerup = Instantiate(prefabMoreArms, transform.position, Quaternion.identity);
                    break;
                }
                ItemPowerup pup = powerup.GetComponent <ItemPowerup>();
                pup.SetPlayerPowerup(data.refs.playerPowerup);

                Velocity2D lm = powerup.GetComponent <Velocity2D>();
                lm.SetVelocity(leftMovement.GetVelocity());
                powerup.GetComponent <TimeScale>().SetData(timeScale);
            }
        }
    }
コード例 #7
0
 public void SetAngleSpeed(float angleDegrees, float speed)
 {
     data.angle = angleDegrees;
     data.speed = speed;
     velocity.SetVelocity(UtilHeading2D.HeadingVectorFromDegrees(angleDegrees) * speed);
 }