public static Movement.GenericMovement MovementFromStruct(Movement.MovementStruct movementStruct)
    {
        Movement.GenericMovement result = null;

        if (movementStruct.Bearing == Movement.ManeuverBearing.Straight)
        {
            result = new Movement.StraightMovement(movementStruct.SpeedInt, movementStruct.Direction, movementStruct.Bearing, movementStruct.ColorComplexity);
        }
        else if (movementStruct.Bearing == Movement.ManeuverBearing.KoiogranTurn)
        {
            result = new Movement.KoiogranTurnMovement(movementStruct.SpeedInt, movementStruct.Direction, movementStruct.Bearing, movementStruct.ColorComplexity);
        }
        else if (movementStruct.Bearing == Movement.ManeuverBearing.Turn)
        {
            result = new Movement.TurnMovement(movementStruct.SpeedInt, movementStruct.Direction, movementStruct.Bearing, movementStruct.ColorComplexity);
        }
        else if (movementStruct.Bearing == Movement.ManeuverBearing.Bank)
        {
            result = new Movement.BankMovement(movementStruct.SpeedInt, movementStruct.Direction, movementStruct.Bearing, movementStruct.ColorComplexity);
        }
        else if (movementStruct.Bearing == Movement.ManeuverBearing.SegnorsLoop)
        {
            result = new Movement.SegnorsLoopMovement(movementStruct.SpeedInt, movementStruct.Direction, movementStruct.Bearing, movementStruct.ColorComplexity);
        }
        else if (movementStruct.Bearing == Movement.ManeuverBearing.TallonRoll)
        {
            result = new Movement.TallonRollMovement(movementStruct.SpeedInt, movementStruct.Direction, movementStruct.Bearing, movementStruct.ColorComplexity);
        }
        else if (movementStruct.Bearing == Movement.ManeuverBearing.Stationary)
        {
            result = new Movement.StationaryMovement(movementStruct.SpeedInt, movementStruct.Direction, movementStruct.Bearing, movementStruct.ColorComplexity);
        }

        return(result);
    }
Example #2
0
    public static Transform GetMovementRuler(Movement.GenericMovement movement)
    {
        ResetRuler();

        Transform result = null;

        if (movement != null)
        {
            switch (movement.Bearing)
            {
            case Movement.ManeuverBearing.Straight:
                return(Templates.Find("straight" + movement.Speed));

            case Movement.ManeuverBearing.Bank:
                return(Templates.Find("bank" + movement.Speed));

            case Movement.ManeuverBearing.SegnorsLoop:
                return(Templates.Find("bank" + movement.Speed));

            case Movement.ManeuverBearing.Turn:
                return(Templates.Find("turn" + movement.Speed));

            case Movement.ManeuverBearing.TallonRoll:
                return(Templates.Find("turn" + movement.Speed));

            case Movement.ManeuverBearing.KoiogranTurn:
                return(Templates.Find("straight" + movement.Speed));

            case Movement.ManeuverBearing.Stationary:
                return(null);
            }
        }
        return(result);
    }
Example #3
0
    public static void UpdateAssignedManeuverDial(GenericShip ship, Movement.GenericMovement maneuver)
    {
        if (maneuver == null)
        {
            return;
        }

        GameObject maneuverDial = ship.InfoPanel.transform.Find("AssignedManeuverDial").gameObject;
        Image      dialImage    = maneuverDial.transform.Find("Holder").GetComponent <Image>();

        dialImage.sprite = Resources.Load <Sprite>("Sprites/Dials/" + Editions.Edition.Current.NameShort + "/Flipped");

        Text maneuverSpeed = maneuverDial.transform.Find("Holder").Find("ManeuverSpeed").GetComponent <Text>();

        maneuverSpeed.text  = maneuver.Speed.ToString();
        maneuverSpeed.color = maneuver.GetColor();
        maneuverSpeed.gameObject.SetActive(ship.Owner.IsNeedToShowManeuver(ship));

        Text maneuverBearing = maneuverDial.transform.Find("Holder").Find("ManeuverBearing").GetComponent <Text>();

        maneuverBearing.text  = maneuver.GetBearingChar();
        maneuverBearing.color = maneuver.GetColor();
        maneuverBearing.gameObject.SetActive(ship.Owner.IsNeedToShowManeuver(ship));

        maneuverDial.SetActive(true);
    }
Example #4
0
    public Movement.GenericMovement MovementFromString(string parameters)
    {
        Movement.MovementStruct movementStruct = ManeuverFromString(parameters);

        string[] arrParameters = parameters.Split('.');
        int      speed         = int.Parse(arrParameters[0]);

        Movement.GenericMovement result = null;

        if (movementStruct.Bearing == Movement.ManeuverBearing.Straight)
        {
            result = new Movement.StraightMovement(speed, movementStruct.Direction, movementStruct.Bearing, movementStruct.ColorComplexity);
        }
        else if (movementStruct.Bearing == Movement.ManeuverBearing.KoiogranTurn)
        {
            result = new Movement.KoiogranTurnMovement(speed, movementStruct.Direction, movementStruct.Bearing, movementStruct.ColorComplexity);
        }
        else if (movementStruct.Bearing == Movement.ManeuverBearing.Turn)
        {
            result = new Movement.TurnMovement(speed, movementStruct.Direction, movementStruct.Bearing, movementStruct.ColorComplexity);
        }
        else if (movementStruct.Bearing == Movement.ManeuverBearing.Bank)
        {
            result = new Movement.BankMovement(speed, movementStruct.Direction, movementStruct.Bearing, movementStruct.ColorComplexity);
        }

        return(result);
    }
Example #5
0
        public MovementPrediction(GenericMovement movement)
        {
            CurrentMovement = movement;

            Selection.ThisShip.ToggleColliders(false);
            GenerateShipStands();
        }
Example #6
0
 private Movement.GenericMovement AdjustDirection(Movement.GenericMovement movement, float vector)
 {
     Movement.GenericMovement result = movement;
     if (movement.Direction != Movement.ManeuverDirection.Forward)
     {
         movement.Direction = (vector < 0) ? Movement.ManeuverDirection.Left : Movement.ManeuverDirection.Right;
     }
     return(result);
 }
Example #7
0
        public MovementPrediction(GenericMovement movement)
        {
            currentMovement = movement;
            Selection.ThisShip.ToggleColliders(false);
            GenerateShipStands();

            GameManagerScript Game = GameObject.Find("GameManager").GetComponent <GameManagerScript>();

            Game.Movement.FuncsToUpdate.Add(UpdateColisionDetection);
        }
Example #8
0
    public Movement.GenericMovement GetManeuver(Ship.GenericShip thisShip, Ship.GenericShip anotherShip)
    {
        float vector    = Actions.GetVector(thisShip, anotherShip);
        bool  isClosing = Actions.IsClosing(thisShip, anotherShip);

        if (inDebug)
        {
            Debug.Log("Vector: " + vector + ", Closing: " + isClosing);
        }
        Movement.GenericMovement result = GetManeuverFromTable(vector, isClosing);
        return(result);
    }
Example #9
0
    public static void ApplyMovementRuler(Ship.GenericShip thisShip, Movement.GenericMovement movement)
    {
        CurrentTemplate = GetMovementRuler(movement);

        SaveCurrentMovementRulerPosition();

        CurrentTemplate.position    = thisShip.GetPosition();
        CurrentTemplate.eulerAngles = thisShip.GetAngles() + new Vector3(0f, 90f, 0f);
        if (movement.Direction == Movement.ManeuverDirection.Left)
        {
            CurrentTemplate.eulerAngles = CurrentTemplate.eulerAngles + new Vector3(180f, 0f, 0f);
        }
    }
Example #10
0
    public static Movement.GenericMovement MovementFromStruct(Movement.ManeuverHolder movementStruct)
    {
        Movement.GenericMovement result = null;

        if (movementStruct.Bearing == Movement.ManeuverBearing.Straight)
        {
            result = new Movement.StraightMovement(movementStruct.SpeedInt, movementStruct.Direction, movementStruct.Bearing, movementStruct.ColorComplexity);
        }
        else if (movementStruct.Bearing == Movement.ManeuverBearing.KoiogranTurn)
        {
            result = new Movement.KoiogranTurnMovement(movementStruct.SpeedInt, movementStruct.Direction, movementStruct.Bearing, movementStruct.ColorComplexity);
        }
        else if (movementStruct.Bearing == Movement.ManeuverBearing.Turn)
        {
            result = new Movement.TurnMovement(movementStruct.SpeedInt, movementStruct.Direction, movementStruct.Bearing, movementStruct.ColorComplexity);
        }
        else if (movementStruct.Bearing == Movement.ManeuverBearing.Bank)
        {
            result = new Movement.BankMovement(movementStruct.SpeedInt, movementStruct.Direction, movementStruct.Bearing, movementStruct.ColorComplexity);
        }
        else if (movementStruct.Bearing == Movement.ManeuverBearing.SegnorsLoop)
        {
            result = new Movement.SegnorsLoopMovement(movementStruct.SpeedInt, movementStruct.Direction, movementStruct.Bearing, movementStruct.ColorComplexity);
        }
        else if (movementStruct.Bearing == Movement.ManeuverBearing.SegnorsLoopUsingTurnTemplate)
        {
            result = new Movement.SegnorsLoopUsingTurnTemplateMovement(movementStruct.SpeedInt, movementStruct.Direction, movementStruct.Bearing, movementStruct.ColorComplexity);
        }
        else if (movementStruct.Bearing == Movement.ManeuverBearing.TallonRoll)
        {
            result = new Movement.TallonRollMovement(movementStruct.SpeedInt, movementStruct.Direction, movementStruct.Bearing, movementStruct.ColorComplexity);
        }
        else if (movementStruct.Bearing == Movement.ManeuverBearing.Stationary)
        {
            result = new Movement.StationaryMovement(movementStruct.SpeedInt, movementStruct.Direction, movementStruct.Bearing, movementStruct.ColorComplexity);
        }
        else if (movementStruct.Bearing == Movement.ManeuverBearing.Reverse)
        {
            if (movementStruct.Direction == Movement.ManeuverDirection.Forward)
            {
                result = new Movement.ReverseStraightMovement(movementStruct.SpeedInt, movementStruct.Direction, movementStruct.Bearing, movementStruct.ColorComplexity);
            }
            else
            {
                result = new Movement.ReverseBankMovement(movementStruct.SpeedInt, movementStruct.Direction, movementStruct.Bearing, movementStruct.ColorComplexity);
            }
        }

        return(result);
    }
Example #11
0
    public static void UpdateAssignedManeuverDial(GenericShip ship, Movement.GenericMovement maneuver)
    {
        GameObject maneuverDial = ship.InfoPanel.transform.Find("AssignedManeuverDial").gameObject;

        Text maneuverSpeed = maneuverDial.transform.Find("Holder").Find("ManeuverSpeed").GetComponent <Text>();

        maneuverSpeed.text  = maneuver.Speed.ToString();
        maneuverSpeed.color = maneuver.GetColor();
        maneuverSpeed.gameObject.SetActive(ship.Owner.IsNeedToShowManeuver(ship));

        Text maneuverBearing = maneuverDial.transform.Find("Holder").Find("ManeuverBearing").GetComponent <Text>();

        maneuverBearing.text  = maneuver.GetBearingChar();
        maneuverBearing.color = maneuver.GetColor();
        maneuverBearing.gameObject.SetActive(ship.Owner.IsNeedToShowManeuver(ship));

        maneuverDial.SetActive(true);
    }
Example #12
0
        private GenericMovement AdjustDirection(Movement.GenericMovement movement, float vector)
        {
            GenericMovement result = movement;

            if (movement.Direction != ManeuverDirection.Forward)
            {
                if (vector < 0)
                {
                    if (movement.Direction == ManeuverDirection.Left)
                    {
                        movement.Direction = ManeuverDirection.Right;
                    }
                    else if (movement.Direction == ManeuverDirection.Right)
                    {
                        movement.Direction = ManeuverDirection.Left;
                    }
                }
            }
            return(result);
        }
Example #13
0
    private static Transform GetMovementRuler(Movement.GenericMovement movement)
    {
        Transform result = null;

        switch (movement.Bearing)
        {
        case Movement.ManeuverBearing.Straight:
            return(Templates.Find("straight" + movement.Speed));

        case Movement.ManeuverBearing.Bank:
            return(Templates.Find("bank" + movement.Speed));

        case Movement.ManeuverBearing.Turn:
            return(Templates.Find("turn" + movement.Speed));

        case Movement.ManeuverBearing.KoiogranTurn:
            return(Templates.Find("straight" + movement.Speed));
        }
        return(result);
    }
Example #14
0
    public Movement.GenericMovement GetManeuverFromTable(float vector, bool isClosing)
    {
        List <string> table           = null;
        bool          adjustDirection = false;

        if (isClosing)
        {
            if ((vector > -22.5f) && (vector < 22.5f))
            {
                if (inDebug)
                {
                    Debug.Log("FrontManeuversInner");
                }
                table = FrontManeuversInner;
            }
            else if (((vector >= 22.5f) && (vector < 67.5f)) || ((vector <= -22.5f) && (vector > -67.5f)))
            {
                if (inDebug)
                {
                    Debug.Log("FrontSideManeuversInner");
                }
                table           = FrontSideManeuversInner;
                adjustDirection = true;
            }
            else if (((vector >= 67.5f) && (vector < 112.5f)) || ((vector <= -67.5f) && (vector > -112.5f)))
            {
                if (inDebug)
                {
                    Debug.Log("SideManeuversInner");
                }
                table           = SideManeuversInner;
                adjustDirection = true;
            }
            else if (((vector >= 112.5f) && (vector < 157.5f)) || ((vector <= -112.5f) && (vector > -157.5f)))
            {
                if (inDebug)
                {
                    Debug.Log("BackSideManeuversInner");
                }
                table           = BackSideManeuversInner;
                adjustDirection = true;
            }
            else if ((vector >= 157.5f) || (vector <= -157.5f))
            {
                if (inDebug)
                {
                    Debug.Log("BackManeuversInner");
                }
                table = BackManeuversInner;
            }
        }
        else
        {
            if ((vector > -22.5f) && (vector < 22.5f))
            {
                if (inDebug)
                {
                    Debug.Log("FrontManeuversOuter");
                }
                table = FrontManeuversOuter;
            }
            else if (((vector >= 22.5f) && (vector < 67.5f)) || ((vector <= -22.5f) && (vector > -67.5f)))
            {
                if (inDebug)
                {
                    Debug.Log("FrontSideManeuversOuter");
                }
                table           = FrontSideManeuversOuter;
                adjustDirection = true;
            }
            else if (((vector >= 67.5f) && (vector < 112.5f)) || ((vector <= -67.5f) && (vector > -112.5f)))
            {
                if (inDebug)
                {
                    Debug.Log("SideManeuversOuter");
                }
                table           = SideManeuversOuter;
                adjustDirection = true;
            }
            else if (((vector >= 112.5f) && (vector < 157.5f)) || ((vector <= -112.5f) && (vector > -157.5f)))
            {
                if (inDebug)
                {
                    Debug.Log("BackSideManeuversOuter");
                }
                table           = BackSideManeuversOuter;
                adjustDirection = true;
            }
            else if ((vector >= 157.5f) || (vector <= -157.5f))
            {
                if (inDebug)
                {
                    Debug.Log("BackManeuversOuter");
                }
                table = BackManeuversOuter;
            }
        }

        Movement.GenericMovement result = RandomManeuverFromTable(table);
        if (adjustDirection)
        {
            if (inDebug)
            {
                Debug.Log("Adjust direction according to vector: " + vector);
            }
            result = AdjustDirection(result, vector);
        }


        return(result);
    }
 public MovementPrediction(GenericShip ship, GenericMovement movement)
 {
     Ship            = ship;
     CurrentMovement = movement;
 }