Esempio n. 1
0
        /// <summary>
        /// Перевод анимации прыгающей сущности в систему координат состояния назначения.
        /// </summary>
        /// <param name="animation">Анимация прыгающей сущности</param>
        /// <param name="destinationState">Состояние назначения</param>
        /// <returns>Анимация прыгающей сущности в системе координат состояния назначения</returns>
        private static EntityAnimation ConvertWarpedEntityAnimation(
            EntityAnimation animation,
            GameState destinationState)
        {
            var oldEntity = animation.Entity;
            //Перевод координат позиции в начале акта прыгающей сущности в систему координат состояния назначения
            //Полученная позиция будет находится за верхней границей карты состояния назначения
            //Она будет являться позицией в начале акта состояния назначения прыгающей сущости
            var     newLocation = ConvertCoordinatesToAnotherState(animation.TargetLocation, destinationState.MapWidth);
            IEntity newEntity;

            //Отображение переносимой сущности из сущности родного состояния в эквивалентную сущность в состоянии назначения
            switch (oldEntity)
            {
            case FriendlyLaserShot friendlyLaserShot:
                newEntity = new EnemyLaserShot(friendlyLaserShot);
                break;

            default:
                throw new ArgumentException(
                          $"Unknown transferring entity {oldEntity.GetType().Name} at location {animation.BeginActLocation}");
            }
            //Получение действия переносимой сущности в состоянии назначения эквивалентного действию в родном состоянии
            var newAction = newEntity.Act(destinationState, newLocation);

            return(new EntityAnimation(newEntity, newAction, newLocation));
        }
Esempio n. 2
0
 //The laser ship has two modes: firing and moving. It enters the screen, fires, and moves out.
 void Update()
 {
     if (active)
     {
         if (!dead)
         {
             if (fireDuration > 0 && transform.position.z < 90)
             {
                 if (!fired && fireDuration < 4)
                 {
                     laser       = Instantiate(shot, this.transform.position, this.transform.rotation) as EnemyLaserShot;
                     laser.speed = shotSpeed;
                     fired       = true;
                 }
                 else
                 {
                     if (fired)
                     {
                         laser.GetComponent <TrailRenderer> ().time += Time.deltaTime;
                     }
                     fireDuration -= Time.deltaTime;
                     this.transform.Rotate(new Vector3(0.0f, 0.0f, 1.0f));
                 }
             }
             else
             {
                 Move();
                 this.transform.rotation = Quaternion.Lerp(this.transform.rotation, Quaternion.Euler(Vector3.zero), Time.deltaTime);
             }
         }
         else
         {
             Move();
         }
     }
     else
     {
         CheckActive();
     }
 }
Esempio n. 3
0
    void OnTriggerEnter2D(Collider2D col)
    {
        EnemyLaserShot enemyMissile = col.GetComponent <EnemyLaserShot>();

        if (enemyMissile)
        {
            Instantiate(smallHit, new Vector3(transform.position.x, transform.position.y + 0.6f, transform.position.z), Quaternion.identity);
            //Destroy (smallHit,3.0f);
            health -= enemyMissile.DamageTaken();
            enemyMissile.HitDone();

            if (health < 0)
            {
                PlayerDefeat();
            }
            else
            {
                Destroy(healthIconObject[iconIndex]);
                iconIndex++;
            }
        }
    }