예제 #1
0
파일: Avatar.cs 프로젝트: mitjmcc/Dogfight
 /// <summary>
 /// Initialize the specified playerField and targetField.
 /// </summary>
 /// <param name="playerField">Player field.</param>
 /// <param name="targetField">Target field.</param>
 public void Initialize(PlayerFieldController playerField, PlayerFieldController targetField)
 {
     this.fieldController = playerField;
     for (int i = 0; i < attackPatterns.Length; i++)
     {
         if (attackPatterns[i] != null)
         {
             attackPatterns[i].TargetField = targetField;
         }
     }
 }
예제 #2
0
    /// <summary>
    /// Initialize the specified fieldController, playerAvatar and targetField.
    /// </summary>
    /// <param name="fieldController">Field controller.</param>
    /// <param name="playerAvatar">Player avatar.</param>
    /// <param name="targetField">Target field.</param>
    public override void Initialize(PlayerFieldController fieldController, Avatar playerAvatar, PlayerFieldController targetField)
    {
        base.Initialize(fieldController, playerAvatar, targetField);
        string strPlay      = "Player ";
        int    playerNumber = fieldController.PlayerNumber;

        horizontalMoveAxis = "Horizontal Movement " + strPlay + playerNumber;
        verticalMoveAxis   = "Vertical Movement " + strPlay + playerNumber;
        focusButton        = "Focus " + strPlay + playerNumber;
        fireButton         = "Fire " + strPlay + playerNumber;
        chargeButton       = "Charge " + strPlay + playerNumber;
    }
예제 #3
0
    /// <summary>
    /// Start this instance.
    /// </summary>
    void Start()
    {
        PlayerFieldController[] controllers = FindObjectsOfType <PlayerFieldController> ();
        float minDist = float.MaxValue;

        for (int i = 0; i < controllers.Length; i++)
        {
            float dist = (controllers[i].transform.position - transform.position).magnitude;
            if (dist < minDist)
            {
                field   = controllers[i];
                minDist = dist;
            }
        }
        StartCoroutine(Move());
    }
예제 #4
0
    void OnSceneGUI()
    {
        Texture2D curveTex = new Texture2D(1, 1);

        curveTex.SetPixel(0, 0, Color.white);
        FieldMovementPattern fmp = (FieldMovementPattern)target;

        FieldMovementPattern.AtomicMovement[] movements = fmp.movements;
        PlayerFieldController testField = fmp.field;

        if (testField != null)
        {
            testField.RecomputeWorldPoints();
            Vector3 currentLocation = testField.WorldPoint(Util.To3D(fmp.testStartPoint));
            for (int i = 0; i < movements.Length; i++)
            {
                if (movements[i] != null)
                {
                    Vector3 nextLocation = movements[i].NextLocation(testField, currentLocation);
                    Vector3 control1     = movements[i].NextControlPoint1(testField, currentLocation);
                    Vector3 control2     = movements[i].NextControlPoint2(testField, currentLocation);
                    if (movements[i].movementType == FieldMovementPattern.MovementType.Linear)
                    {
                        Handles.DrawLine(currentLocation, nextLocation);
                    }
                    else
                    {
                        Handles.DrawDottedLine(currentLocation, control1, 10f);
                        Handles.DrawWireDisc(control1, Vector3.forward, 1);
                        Handles.DrawDottedLine(control1, control2, 10f);
                        Handles.DrawWireDisc(control2, Vector3.forward, 1f);
                        Handles.DrawDottedLine(control2, nextLocation, 10f);
                        Handles.DrawBezier(currentLocation, nextLocation, control1, control2, Handles.color, curveTex, 1f);
                    }
                    currentLocation = nextLocation;
                    Handles.DrawWireDisc(currentLocation, Vector3.forward, 1);
                }
            }
        }
    }
예제 #5
0
        /// <summary>
        /// Interpret the specified loc, field and startLocation.
        /// </summary>
        /// <param name="loc">Location.</param>
        /// <param name="field">Field.</param>
        /// <param name="startLocation">Start location.</param>
        private Vector3 Interpret(Vector2 loc, PlayerFieldController field, Vector3 startLocation)
        {
            Vector3 nextLocation = Util.To3D(loc);

            switch (locationType)
            {
            case FieldMovementPattern.LocationType.Relative:
                return(startLocation + field.Relative2Absolute(nextLocation));

            case FieldMovementPattern.LocationType.Absolute:
                return(field.Relative2Absolute(nextLocation));

            case FieldMovementPattern.LocationType.WorldRelative:
                return(startLocation + nextLocation);

            case FieldMovementPattern.LocationType.WorldAbsolute:
                return(startLocation);

            default:
                return(Vector3.zero);
            }
        }
예제 #6
0
 /// <summary>
 /// Nexts the control point1.
 /// </summary>
 /// <returns>The control point1.</returns>
 /// <param name="field">Field.</param>
 /// <param name="startLocation">Start location.</param>
 public Vector3 NextControlPoint1(PlayerFieldController field, Vector3 startLocation)
 {
     return(Interpret(curveControlPoint1, field, startLocation));
 }
예제 #7
0
 /// <summary>
 /// Nexts the location.
 /// </summary>
 /// <returns>The location.</returns>
 /// <param name="field">Field.</param>
 /// <param name="startLocation">Start location.</param>
 public Vector3 NextLocation(PlayerFieldController field, Vector3 startLocation)
 {
     return(Interpret(targetLocation, field, startLocation));
 }
예제 #8
0
 /// <summary>
 /// Initialize the specified fieldController, playerAvatar and targetField.
 /// </summary>
 /// <param name="fieldController">Field controller.</param>
 /// <param name="playerAvatar">Player avatar.</param>
 /// <param name="targetField">Target field.</param>
 public virtual void Initialize(PlayerFieldController fieldController, Avatar playerAvatar, PlayerFieldController targetField)
 {
     this.fieldController = fieldController;
     this.playerAvatar    = playerAvatar;
     playerAvatar.Initialize(fieldController, targetField);
 }
예제 #9
0
    /// <summary>
    /// Transfer the specified currentController and targetField.
    /// </summary>
    /// <param name="currentController">Current controller.</param>
    /// <param name="targetField">Target field.</param>
    public void Transfer(PlayerFieldController currentController, PlayerFieldController targetField)
    {
        Vector2 relativePos = currentController.FieldPoint(Transform.position);

        Transform.position = targetField.WorldPoint(relativePos);
    }