Exemplo n.º 1
0
    private IEnumerator MultiGunRotationHandler()
    {
        yield return(null);

        yield return(null);

        while (true)
        {
            yield return(null);

            if (!isRunning)
            {
                continue;
            }
            if (targetsToActUpon.Count == 0)
            {
                continue;
            }
            if (rotatingParts.Length == 0)
            {
                continue;
            }

            // todo: include priority.
            TrackTargetEvent target = targetsToActUpon[targetsToActUpon.Count - 1];
            Debug.Log("assigned target to " + transform.root + target.target + target.context);
            AQAccess.Ins.SetData(transform.root.GetComponentInChildren <ShipAI>(), "Target", target.target);

            // last one is assumed to be root
            // todo: make it safer.
            RotatingTurretTop rotatingPart = rotatingParts[rotatingParts.Length - 1];

            foreach (var turretTracking in eachTurretTrackingType)
            {
                switch (turretTracking)
                {
                case AbandomPriority.AimedOnce:
                    RotateToTarget(rotatingPart, target);
                    break;

                case AbandomPriority.OnDeath:
                    break;

                case AbandomPriority.OnLoseRange:
                    break;

                case AbandomPriority.OnInRange:
                    break;

                case AbandomPriority.AfterNextShotCommand:
                    break;

                default:
                    break;
                }
            }
            targetsToActUpon.RemoveAt(targetsToActUpon.Count - 1);
        }
    }
Exemplo n.º 2
0
    private void RotateToTarget(RotatingTurretTop rotatingPart, TrackTargetEvent target)
    {
        if (transform.root == target.target.root)
        {
            Debug.LogError("Aiming at itself", this);
        }

        switch (target.idleMoving)
        {
        case TargetType.Moving:

            rotatingPart.TurnToPoint(target.target.position);
            break;

        case TargetType.NonMoving:
            rotatingPart.TurnToPoint(target.target.position);
            break;

        default:
            break;
        }
    }