示例#1
0
文件: UsualBullet.cs 项目: UDK/SoV
 private void Update()
 {
     if (Target == null)
     {
         ShellCollection <UsualBullet> .Destroy(gameObject);
     }
     if (Vector3.Distance(transform.position, _startPosition) > LifeDistance)
     {
         ShellCollection <UsualBullet> .Destroy(gameObject);
     }
 }
示例#2
0
文件: UsualBullet.cs 项目: UDK/SoV
        private void OnCollisionEnter2D(Collision2D collision)
        {
            var go = collision.gameObject.GetComponent <IGameplayObject>();

            if (go == null ||
                go.AllianceGuid == AllianceGuid)
            {
                return;
            }

            go.MakeDamage(BaseDamage);
            ShellCollection <UsualBullet> .Destroy(gameObject);
        }
示例#3
0
文件: ShellHelper.cs 项目: UDK/SoV
        public static void InitShell <TShell>(
            GameObject originalShell,
            GameObject target,
            Vector3 startPosition,
            Guid allianceGuid)
            where TShell : MonoBehaviour
        {
            var shell = ShellCollection <TShell> .Get(
                originalShell,
                startPosition,
                originalShell.transform.rotation);

            var iShell          = shell.GetComponent <IShell>();
            var iGameplayObject = shell.GetComponent <IGameplayObject>();

            iGameplayObject.AllianceGuid = allianceGuid;
            iShell.Target = target;
            iShell.Initiate();
        }
示例#4
0
文件: UsualRocket.cs 项目: UDK/SoV
 private void FixedUpdate()
 {
     if (Target == null)
     {
         ShellCollection <UsualRocket> .Destroy(gameObject);
     }
     if (Homing)
     {
         var heading = Target.transform.position - transform.position;
         _movementBehaviour.SetVelocity(heading.normalized * _movementBehaviour.MaxVelocity);
         float angle = Mathf.Atan2(_movementBehaviour.Velocity.y,
                                   _movementBehaviour.Velocity.x) * Mathf.Rad2Deg;
         transform.rotation = Quaternion.AngleAxis(angle, Vector3.forward);
     }
     else
     {
         if (Vector3.Distance(transform.position, _startPosition) > LifeDistance)
         {
             ShellCollection <UsualRocket> .Destroy(gameObject);
         }
     }
 }