public void Retrieve() { if (State == HarpoonState.Locked) { Harpoon.GetComponent <HarpoonController>().Unlock(); } State = HarpoonState.Retrieving; }
public HarpoonAttackManager(Spaceship attacker, Vector2 position, Vector2 direction, Vector2 initialVelocity, float damage, float speed, float range, float duration) { Attacker = attacker; Damage = damage; State = HarpoonState.Fireing; Harpoon = GameManager.Instance.Instantiate(GeneralPrefabs.Instance.Harpoon, Vector2.zero, Quaternion.identity); Harpoon.GetComponent <HarpoonController>().Initialize(this, attacker, position, direction, initialVelocity, speed, range, duration); }
public void Shoot(Vector3 pos, Vector3 velocity, float maxDist) { if (harpoonState == HarpoonState.Waiting) { gameObject.transform.position = pos; this.harpoonState = HarpoonState.Shooting; this.maxDistance = maxDist; this.Velocity = velocity; } }
private void UpdateShooting(float delta) { var curPos = gameObject.transform.position; gameObject.transform.position = new Vector3(curPos.x + Velocity.x * delta * GameConfig.HarpoonSpeed, curPos.y + Velocity.y * delta * GameConfig.HarpoonSpeed); distance += Mathf.Abs(Velocity.x * Time.deltaTime * GameConfig.HarpoonSpeed) + Mathf.Abs(Velocity.y * Time.deltaTime * GameConfig.HarpoonSpeed); if (distance >= maxDistance) { distance = 0; harpoonState = HarpoonState.Retrieving; } }
private void Grab(GameObject enemy) { this.grabbedGameObject = enemy; enemy.transform.position = gameObject.transform.position; var enemySprite = enemy.GetComponent <SpriteRenderer>(); enemySprite.sortingOrder = -1; enemy.transform.SetParent(gameObject.transform); var enemyScript = enemy.GetComponent <EnemyScript>(); enemyScript.Capture(); harpoonState = HarpoonState.Retrieving; }
private void UpdateRetrieving(float delta) { var curPos = gameObject.transform.position; var dest = gameController.player.transform.position; gameObject.transform.position = Vector3.MoveTowards(curPos, dest, GameConfig.HarpoonSpeed / GameConfig.HarpoonDist * delta); if (Vector3.Distance(curPos, dest) < .1) { if (grabbedGameObject != null) { gameController.playerController.AddEnemy(grabbedGameObject); //gameController.playerController.playerState = PlayerState.Captive; } harpoonState = HarpoonState.Waiting; } }
// Use this for initialization void Start() { this.distance = 0; this.harpoonState = HarpoonState.Waiting; }
public void Expire() { State = HarpoonState.Expired; }
public void LockHarpoon(Spaceship other) { State = HarpoonState.Locked; other.TakeDamage(this, Damage, DamageType.Physical); Harpoon.GetComponent <HarpoonController>().Lock(other); }