private void Start() { velocity.SetVelocity( Angle.FromDegrees(data.angle).GetHeadingVector() * data.speed); //UtilHeading2D.HeadingVectorFromDegrees(data.angle) * data.speed); SetColor(data.color); }
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; }
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); }
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); }
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); }
// 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); } } }
public void SetAngleSpeed(float angleDegrees, float speed) { data.angle = angleDegrees; data.speed = speed; velocity.SetVelocity(UtilHeading2D.HeadingVectorFromDegrees(angleDegrees) * speed); }