public void LookAt(Vector3 target) { if (!_moving) { _desiredDirection = Iso.Direction(iso.pos, target, DirectionCount); } }
public static Missile Create(MissileInfo missileInfo, Vector3 start, Vector3 target, Character originator) { var gameObject = new GameObject("missile_" + missileInfo.missile); var missile = gameObject.AddComponent <Missile>(); missile.animator = gameObject.AddComponent <SpriteAnimator>(); missile.renderer = gameObject.GetComponent <SpriteRenderer>(); missile.iso = gameObject.AddComponent <Iso>(); missile.info = missileInfo; missile.originator = originator; missile.speed = missileInfo.velocity; missile.iso.pos = start; missile.dir = (target - start).normalized; missile.renderer.material = missileInfo.material; missile.skillInfo = SkillInfo.Find(missileInfo.skill); missile.lifeTime = 0; var spritesheet = Spritesheet.Load(missileInfo.spritesheetFilename); int direction = Iso.Direction(start, target, spritesheet.directionCount); missile.animator.sprites = spritesheet.GetSprites(direction); missile.animator.loop = missileInfo.loopAnim != 0; missile.animator.fps = missileInfo.fps; AudioManager.instance.Play(missileInfo.travelSound, missile.transform); return(missile); }
void MoveAlongPath() { Vector2 step = path[0].direction; float stepLen = step.magnitude; Vector2 movement = new Vector3(); float speed = run ? runSpeed : walkSpeed; float distance = speed * Time.deltaTime; while (_traveled + distance >= stepLen) { float part = stepLen - _traveled; movement += step.normalized * part; distance -= part; _traveled = 0; path.RemoveAt(0); if (path.Count > 0) { step = path[0].direction; stepLen = step.magnitude; } else { break; } } if (path.Count > 0) { _traveled += distance; movement += step.normalized * distance; } Move(movement); if (path.Count == 0) { _traveled = 0; } else if (_moving) { _desiredDirection = Iso.Direction(iso.pos, iso.pos + step, DirectionCount); } }
public void LookAtImmediately(Vector3 target) { _directionIndex = _desiredDirection = Iso.Direction(iso.pos, target, DirectionCount); }
public void LookAtImmidietly(Vector3 target) { directionIndex = desiredDirection = Iso.Direction(iso.pos, target, directionCount); }