Exemplo n.º 1
0
 public override void UpdateState()
 {
     if (!canInterrupt && loopOmega * (Time.time - startTime) >= 2 * Math.PI)
     {
         executedManeuver = new MakeCircle(executedManeuver.CalculateWorldPosition(), executedManeuver.CalculateWorldRotation(), circleOmega, circleRadius);
         canInterrupt     = true;
     }
 }
        public override void UpdateState()
        {
            executedManeuver.UpdateState();
            Vector3    position = executedManeuver.CalculateWorldPosition();
            Quaternion rotation = executedManeuver.CalculateWorldRotation();

            if (stage == (int)stagesOfAttack.initialAttackCircle && Vector3.Angle(rotation * Vector3.forward, position - new Vector3(AttackCoords.x, position.y, AttackCoords.z)) < permissibleAngleErrorDegrees)
            {
                stage = (int)stagesOfAttack.straightFlightToTarget;
                Vector3 planesRight = rotation * Vector3.right;
                planesRight.y = 0;
                planesRight.Normalize();
                finalCoords = position - 2 * radius * planesRight;
                //the "forward" vector in the LookRotation call is multpiplied by -1 because the forward vector of the Hercules model is towards its tail
                executedManeuver = new StraightFlightManeuver(position, AttackCoords, flightSpeed, rotation);
            }
            if (stage == (int)stagesOfAttack.straightFlightToTarget && ((StraightFlightManeuver)executedManeuver).finished)
            {
                stage = (int)stagesOfAttack.circleSegmentAboveTarget;
                try
                {
                    building.GetComponent <BuildingDisplay>().BoomBuilding();
                }
                catch { }
                MapCommands.Instance.UnlockMap();
                executedManeuver = new MakeCircle(position, rotation, omega, radius);
                //Vector3[] pos = { new Vector3() };
                //line.SetPositions(pos);
                line.SetActive(false);
            }
            if (stage == (int)stagesOfAttack.circleSegmentAboveTarget && Vector3.Angle(rotation * Vector3.forward, position - new Vector3(finalCoords.x, position.y, finalCoords.z)) < permissibleAngleErrorDegrees)
            {
                stage            = (int)stagesOfAttack.straightFlightBackToCircle;
                executedManeuver = new StraightFlightManeuver(position, finalCoords, flightSpeed, rotation);
            }
            if (stage == (int)stagesOfAttack.straightFlightBackToCircle && ((StraightFlightManeuver)executedManeuver).finished)
            {
                alphaOnTargetRecord.Play();
                stage            = (int)stagesOfAttack.finalCircle;
                executedManeuver = new MakeCircle(position, rotation, omega, radius);
            }
        }