Esempio n. 1
0
        protected MovementStruct GetSimilarManeuverByStruct(MovementStruct alternativeManeuverStruct)
        {
            MovementStruct result = alternativeManeuverStruct;

            if (!Selection.ThisShip.HasManeuver(result) || (failedManeuvers.Contains(result)))
            {
                if (result.Speed == ManeuverSpeed.Speed1)
                {
                    result.SpeedInt++;
                }
                else
                {
                    result.SpeedInt--;
                    if (!Selection.ThisShip.HasManeuver(result) || (failedManeuvers.Contains(result)))
                    {
                        result.SpeedInt--;
                        if (!Selection.ThisShip.HasManeuver(result) || (failedManeuvers.Contains(result)))
                        {
                            result.SpeedInt--;  //for example, 5 bank -> 2 bank
                        }
                    }
                }
            }

            result.UpdateColorComplexity();
            return(result);
        }
Esempio n. 2
0
        protected virtual void TryAlternativeMovement()
        {
            if (alternativeManeuvers.Count > 0)
            {
                MovementStruct maneuver = alternativeManeuvers[0];
                alternativeManeuvers.Remove(alternativeManeuvers[0]);

                if (failedManeuvers.Contains(maneuver))
                {
                    TryAlternativeMovement();
                }
                else
                {
                    GenericMovement newMovementAttempt = ShipMovementScript.MovementFromStruct(maneuver);

                    if (DebugManager.DebugAI)
                    {
                        Debug.Log("Tries: " + newMovementAttempt);
                    }

                    Selection.ThisShip.SetAssignedManeuver(newMovementAttempt);
                    newMovementAttempt.Initialize();
                    movementPrediction = new MovementPrediction(newMovementAttempt, CheckSwerveAlternativePrediction);
                }
            }
            else
            {
                Console.Write("Ship doesn't see alternatives to the asteroid collision", LogTypes.AI, false, "yellow");
                Selection.ThisShip.SetAssignedManeuver(originalMovement);
                Selection.ThisShip.AssignedManeuver.LaunchShipMovement();
            }
        }
Esempio n. 3
0
 private void CheckAbility(GenericShip ship, ref MovementStruct movement)
 {
     if (HostShip.Shields == 0 && movement.Bearing == ManeuverBearing.Bank)
     {
         movement.ColorComplexity = GenericMovement.ReduceComplexity(movement.ColorComplexity);
     }
 }
        // MANEUVERS

        // TODO: Rewrite
        public ManeuverColor GetColorComplexityOfManeuver(MovementStruct movement)
        {
            if (AfterGetManeuverColorDecreaseComplexity != null) AfterGetManeuverColorDecreaseComplexity(this, ref movement);
            if (AfterGetManeuverColorIncreaseComplexity != null) AfterGetManeuverColorIncreaseComplexity(this, ref movement);
            if (AfterGetManeuverAvailablity != null) AfterGetManeuverAvailablity(this, ref movement);

            return movement.ColorComplexity;
        }
Esempio n. 5
0
        private void ChangeComplexity(GenericShip ship, ref MovementStruct movement)
        {
            if (movement.ToString() == HostShip.AssignedManeuver.ToString())
            {
                return;
            }

            movement.ColorComplexity = GenericMovement.IncreaseComplexity(movement.ColorComplexity);
        }
Esempio n. 6
0
 private void ApplyAbility(GenericShip ship, ref MovementStruct movement)
 {
     if (movement.Speed == ManeuverSpeed.Speed1 || movement.Speed == ManeuverSpeed.Speed2)
     {
         if (movement.Bearing == ManeuverBearing.Straight || movement.Bearing == ManeuverBearing.Bank || movement.Bearing == ManeuverBearing.Turn)
         {
             movement.ColorComplexity = GenericMovement.ReduceComplexity(movement.ColorComplexity);
         }
     }
 }
Esempio n. 7
0
        public Sequence StopCompletelyInternal()
        {
            if (MotionTableManager == null)
            {
                return(new Sequence(7));
            }
            var mvs = new MovementStruct(MovementType.StopCompletely);

            return(MotionTableManager.PerformMovement(mvs, Sequence));
        }
Esempio n. 8
0
 public void CannotPerformRedManeuversWhileStressed(GenericShip ship, ref MovementStruct movement)
 {
     if ((movement.ColorComplexity == MovementComplexity.Complex) && (ship.Tokens.GetToken(typeof(StressToken)) != null))
     {
         if (!ship.CanPerformRedManeuversWhileStressed && !DirectionsMenu.IsForcedToShowRedManeuvers)
         {
             movement.ColorComplexity = MovementComplexity.None;
         }
     }
 }
Esempio n. 9
0
 private void CheckElloAstyAbility(GenericShip ship, ref MovementStruct movement)
 {
     if (movement.Bearing == ManeuverBearing.TallonRoll)
     {
         if (!HostShip.Tokens.HasToken(typeof(Tokens.StressToken)))
         {
             movement.ColorComplexity = ManeuverColor.White;
         }
     }
 }
Esempio n. 10
0
        public WeenieError StopCompletelyInternal()
        {
            if (MotionTableManager == null)
            {
                return(WeenieError.NoAnimationTable);
            }
            var mvs = new MovementStruct(MovementType.StopCompletely);

            return(MotionTableManager.PerformMovement(mvs, Sequence));
        }
Esempio n. 11
0
 private void NienNunbAbility(GenericShip ship, ref MovementStruct movement)
 {
     if (movement.ColorComplexity != MovementComplexity.None)
     {
         if (movement.Bearing == ManeuverBearing.Straight)
         {
             movement.ColorComplexity = MovementComplexity.Easy;
         }
     }
 }
Esempio n. 12
0
 private void NienNunbAbility(GenericShip ship, ref MovementStruct movement)
 {
     if (movement.ColorComplexity != MovementComplexity.None)
     {
         if (movement.Bearing == ManeuverBearing.Bank)
         {
             movement.ColorComplexity = GenericMovement.ReduceComplexity(movement.ColorComplexity);
         }
     }
 }
Esempio n. 13
0
        public WeenieError DoInterpretedMotion(uint motion, MovementParameters movementParameters)
        {
            if (MotionTableManager == null)
            {
                return(WeenieError.NoAnimationTable);
            }

            var mvs = new MovementStruct(MovementType.InterpretedCommand, motion, movementParameters);

            return(MotionTableManager.PerformMovement(mvs, Sequence));
        }
Esempio n. 14
0
        public Sequence DoInterpretedMotion(int motion, MovementParameters movementParameters)
        {
            if (MotionTableManager == null)
            {
                return(new Sequence(7));
            }

            var mvs = new MovementStruct(MovementType.InterpretedCommand, motion, movementParameters);

            return(MotionTableManager.PerformMovement(mvs, Sequence));
        }
Esempio n. 15
0
        private bool IsSameSpeedNotRed(string maneuverString)
        {
            bool           result         = false;
            MovementStruct movementStruct = new MovementStruct(maneuverString);

            if (movementStruct.Speed == HostShip.AssignedManeuver.ManeuverSpeed && movementStruct.ColorComplexity != MovementComplexity.Complex)
            {
                result = true;
            }
            return(result);
        }
Esempio n. 16
0
        public Sequence StopInterpretedMotion(int motion, MovementParameters movementParameters)
        {
            if (MotionTableManager == null)
            {
                return(new Sequence(7));
            }
            var mvs = new MovementStruct(MovementType.StopInterpretedCommand);

            mvs.Motion = motion;
            mvs.Params = movementParameters;
            return(MotionTableManager.PerformMovement(mvs, Sequence));
        }
Esempio n. 17
0
        private bool StraightOrKoiogran(string maneuverString)
        {
            bool           result         = false;
            MovementStruct movementStruct = new MovementStruct(maneuverString);

            if (movementStruct.Speed == Selection.ThisShip.AssignedManeuver.ManeuverSpeed &&
                (movementStruct.Bearing == ManeuverBearing.Straight ||
                 movementStruct.Bearing == ManeuverBearing.KoiogranTurn))
            {
                result = true;
            }
            return(result);
        }
Esempio n. 18
0
        public Sequence StopInterpretedMotion(int motion, MovementParameters movementParameters)
        {
            if (MotionTableManager == null)
            {
                return(null);                               // 7?
            }
            var frame = new Frame();

            frame.Origin      = Vector3.Zero;
            frame.Orientation = Quaternion.Identity;
            // add frame to cache
            var mvs = new MovementStruct();

            return(MotionTableManager.PerformMovement(mvs, Sequence));   // how to add frame/input data?
        }
Esempio n. 19
0
        public Sequence StopCompletelyInternal()
        {
            if (MotionTableManager == null)
            {
                return(null);                               // 7?
            }
            var frame = new Frame();

            frame.Origin      = Vector3.Zero;
            frame.Orientation = Quaternion.Identity;
            // add frame to cache
            var mvs = new MovementStruct();

            return(MotionTableManager.PerformMovement(mvs, Sequence));   // how to add frame data?
        }
Esempio n. 20
0
        public Sequence DoInterpretedMotion(int motion, MovementParameters movementParameters)
        {
            if (MotionTableManager == null)
            {
                return(null);                               // 7?
            }
            var frame = new Frame();

            frame.Origin      = Vector3.Zero;
            frame.Orientation = Quaternion.Identity;    // correct?
            // cache frame
            var mvs = new MovementStruct();

            return(MotionTableManager.PerformMovement(mvs, Sequence));   // mvs.Motion?
        }
Esempio n. 21
0
        // MANEUVERS

        // TODO: Rewrite
        public MovementComplexity GetColorComplexityOfManeuver(MovementStruct movement)
        {
            if (AfterGetManeuverColorDecreaseComplexity != null)
            {
                AfterGetManeuverColorDecreaseComplexity(this, ref movement);
            }
            if (AfterGetManeuverColorIncreaseComplexity != null)
            {
                AfterGetManeuverColorIncreaseComplexity(this, ref movement);
            }
            if (AfterGetManeuverAvailablity != null)
            {
                AfterGetManeuverAvailablity(this, ref movement);
            }

            return(movement.ColorComplexity);
        }
Esempio n. 22
0
        protected virtual void TryAlternativeMovement()
        {
            if (alternativeManeuvers.Count > 0)
            {
                MovementStruct maneuver = alternativeManeuvers[0];
                alternativeManeuvers.Remove(alternativeManeuvers[0]);

                if (failedManeuvers.Contains(maneuver))
                {
                    TryAlternativeMovement();
                }
                else
                {
                    GameManagerScript Game = GameObject.Find("GameManager").GetComponent <GameManagerScript>();
                    GenericMovement   newMovementAttempt = Game.Movement.MovementFromStruct(maneuver);

                    if (DebugManager.DebugAI)
                    {
                        Debug.Log("Tries: " + newMovementAttempt);
                    }

                    newMovementAttempt.Initialize();
                    movementPrediction = new MovementPrediction(newMovementAttempt, CheckSwerveAlternativePrediction);
                }
            }
            else
            {
                if (DebugManager.DebugAI)
                {
                    Messages.ShowInfo("AI doesn't see alternatives to the asteroid collision");
                }
                if (DebugManager.DebugAI)
                {
                    Debug.Log("So AI decides to left it as is...");
                }
                Selection.ThisShip.AssignedManeuver.LaunchShipMovement();
            }
        }
Esempio n. 23
0
    void DrawAnimation()
    {
        if (mData.AnimationSkillList == null)
        {
            return;
        }

        for (int i = 0; i < mData.AnimationSkillList.Count; i++)
        {
            EditorGUILayout.Space();

            AnimationSkillStruct _ass = mData.AnimationSkillList[i];

            if (_ass.IsFoldout)
            {
                EditorGUILayout.BeginVertical(EditorStyles.helpBox);

                EditorGUILayout.LabelField(_ass.Type.ToString());
                if (GUILayout.Button("Preview"))
                {
                    mASD.PlayAnimaState(_ass.Type);
                }

                _ass.AnimationClip = (AnimationClip)EditorGUILayout.ObjectField("AnimaitonClip:", _ass.AnimationClip, typeof(AnimationClip), true);

                EditorGUILayout.BeginHorizontal();
                if (_ass.AnimationClip == null)
                {
                    _ass.fTime = 1f;
                }
                else
                {
                    _ass.fTime = _ass.AnimationClip.length;
                }
                EditorGUILayout.LabelField("NextAnima After:", _ass.fTime.ToString());
                _ass.NextType = (NFAnimaStateType)EditorGUILayout.EnumPopup(_ass.NextType);

                EditorGUILayout.EndHorizontal();

                AnimatorController ctl = (AnimatorController)mASD.GetComponent <Animator> ().runtimeAnimatorController;
                if (ctl != null)
                {
                    AnimatorStateMachine state_machine = ctl.layers[0].stateMachine;
                    for (int j = 0; j < state_machine.states.Length; ++j)
                    {
                        if (state_machine.states [j].state.name == _ass.Type.ToString())
                        {
                            String        strPath = AssetDatabase.GetAssetPath(_ass.AnimationClip);
                            AnimationClip anim    = AssetDatabase.LoadAssetAtPath(strPath, typeof(AnimationClip)) as AnimationClip;
                            state_machine.states [j].state.motion = anim;
                            break;
                        }
                    }
                }

                mData.AnimationSkillList[i] = _ass;

                //添加特效与删除片断
                EditorGUILayout.BeginHorizontal();
                if (GUILayout.Button("ADD EFFECT"))
                {
                    EffectStruct _es = new EffectStruct();
                    _es.LifeTime  = 3;
                    _es.isFoldout = true;
                    mData.AnimationSkillList[i].EffectStructList.Add(_es);
                }
                if (GUILayout.Button("ADD Audio"))
                {
                    AudioStruct _es = new AudioStruct();
                    _es.LifeTime  = 3;
                    _es.isFoldout = true;
                    mData.AnimationSkillList[i].AudioStructList.Add(_es);
                }
                if (GUILayout.Button("ADD Bullet"))
                {
                    BulletStruct _es = new BulletStruct();
                    _es.isFoldout = true;
                    mData.AnimationSkillList[i].BulletStructList.Add(_es);
                }



                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                if (GUILayout.Button("ADD Damage"))
                {
                    DamageStruct _es = new DamageStruct();
                    _es.isFoldout = true;
                    mData.AnimationSkillList[i].DamageStructList.Add(_es);
                }

                if (GUILayout.Button("ADD Movement"))
                {
                    MovementStruct _es = new MovementStruct();
                    _es.isFoldout = true;
                    mData.AnimationSkillList[i].MovementStructList.Add(_es);
                }

                if (GUILayout.Button("ADD Camera"))
                {
                    CameraStruct _es = new CameraStruct();
                    _es.isFoldout = true;
                    mData.AnimationSkillList[i].CameraStructList.Add(_es);
                }

                EditorGUILayout.EndHorizontal();

                if (mData.AnimationSkillList.Count > 0)
                {
                    DrawEffect(i);
                    DrawAudio(i);
                    DrawMovement(i);
                    DrawDamage(i);
                    DrawBullet(i);
                    DrawCamera(i);
                }
                EditorGUILayout.EndVertical();
            }
        }
    }
Esempio n. 24
0
    void DrawMovement(int id)
    {
        if (!(id < mData.AnimationSkillList.Count))
        {
            return;
        }

        for (int i = 0; i < mData.AnimationSkillList[id].MovementStructList.Count; i++)
        {
            MovementStruct _eff = mData.AnimationSkillList[id].MovementStructList[i];

            EditorGUI.indentLevel++;
            EditorGUILayout.BeginVertical(EditorStyles.helpBox);

            string _titleName = "Movement" + (i + 1).ToString();
            EditorGUILayout.BeginHorizontal();
            //此子特效的界面折叠
            _eff.isFoldout = EditorGUILayout.Foldout(_eff.isFoldout, _titleName);
            GUILayout.FlexibleSpace();
            //此子特效是否可用
            _eff.isEnabled = EditorGUILayout.Toggle("", _eff.isEnabled);

            if (GUILayout.Button("DELETE"))
            {
                mData.AnimationSkillList[id].MovementStructList.Remove(_eff);
                return;
            }

            EditorGUILayout.EndHorizontal();

            mData.AnimationSkillList[id].MovementStructList[i] = _eff;

            if (_eff.isFoldout)
            {
                EditorGUI.BeginDisabledGroup(!_eff.isEnabled);
                _eff.DelayTime = EditorGUILayout.FloatField("Delay Time", _eff.DelayTime);
                if (_eff.DelayTime > mData.AnimationSkillList[id].fTime)
                {
                    _eff.DelayTime = mData.AnimationSkillList [id].fTime;
                }

                string[] _nameArry = mData.VirtualPointList.ToArray();

                _eff.StartAudio       = (AudioClip)EditorGUILayout.ObjectField("StartAudio", _eff.StartAudio, typeof(AudioClip), true);
                _eff.StartEffect      = (GameObject)EditorGUILayout.ObjectField("StartEffect", _eff.StartEffect, typeof(GameObject), true);
                _eff.StartEffLifeTime = EditorGUILayout.FloatField("StartEffLifeTime", _eff.StartEffLifeTime);

                //运动方式
                _eff.moveType = (MovementStruct.MoveType)EditorGUILayout.EnumPopup("Move Type", _eff.moveType);
                _eff.Distance = EditorGUILayout.FloatField("Distance", _eff.Distance);
                _eff.Speed    = EditorGUILayout.FloatField("Speed", _eff.Speed);

                _eff.TouchAudio  = (AudioClip)EditorGUILayout.ObjectField("TouchAudio", _eff.TouchAudio, typeof(AudioClip), true);
                _eff.TouchEffect = (GameObject)EditorGUILayout.ObjectField("TouchEffect", _eff.TouchEffect, typeof(GameObject), true);

                _eff.TouchEffLifeTime = EditorGUILayout.FloatField("TouchEffLifeTime", _eff.TouchEffLifeTime);

                mData.AnimationSkillList[id].MovementStructList[i] = _eff;
            }
            EditorGUI.EndDisabledGroup();


            EditorGUILayout.EndVertical();
            EditorGUI.indentLevel--;
        }
    }
Esempio n. 25
0
    IEnumerator WaitPlayMovement(MovementStruct es)
    {
        //如果特效没有启用则不进行播放
        if (es.isEnabled)
        {
            yield return(new WaitForSeconds(es.DelayTime));
        }
        else
        {
            yield break;
        }

        if (es.StartEffect)
        {
            GameObject _startEff = GameObject.Instantiate <GameObject> (es.StartEffect, this.gameObject.transform.position, Quaternion.identity);
            _startEff.SetActive(true);
            Destroy(_startEff, es.StartEffLifeTime);
        }
        if (es.StartAudio)
        {
            AudioClip _startEff = GameObject.Instantiate <AudioClip> (es.StartAudio, this.gameObject.transform.position, Quaternion.identity);
            AudioSource.PlayClipAtPoint(_startEff, transform.position);

            Destroy(_startEff, es.StartEffLifeTime);
        }

        Vector3 vForward   = new Vector3();
        Vector3 vTargetPos = new Vector3();

        switch (es.moveType)
        {
        case MovementStruct.MoveType.Forward:
        {
            vForward = this.gameObject.transform.forward;
        }
        break;

        case MovementStruct.MoveType.Back:
        {
            vForward = -this.gameObject.transform.forward;
        }
        break;

        case MovementStruct.MoveType.Left:
        {
            vForward = -this.gameObject.transform.right;
        }
        break;

        case MovementStruct.MoveType.Right:
        {
            vForward = this.gameObject.transform.right;
        }
        break;

        default:
            break;
        }

        vTargetPos = vForward * es.Distance + this.transform.position;

        float   fDis = Vector3.Distance(vTargetPos, this.transform.position);
        Tweener t    = this.transform.DOMove(vTargetPos, fDis / es.Speed);

        t.OnComplete(delegate()
        {
            if (es.TouchEffect)
            {
                GameObject _startEff = GameObject.Instantiate <GameObject> (es.TouchEffect, vTargetPos, Quaternion.identity);
                _startEff.SetActive(true);
                Destroy(_startEff, es.TouchEffLifeTime);
            }
            if (es.TouchAudio)
            {
                AudioClip _startEff = GameObject.Instantiate <AudioClip> (es.TouchAudio, vTargetPos, Quaternion.identity);
                AudioSource.PlayClipAtPoint(_startEff, transform.position);

                Destroy(_startEff, es.TouchEffLifeTime);
            }
        });

        yield return(new WaitForEndOfFrame());
    }
Esempio n. 26
0
        protected virtual List <MovementStruct> GetAlternativeManeuvers(GenericMovement maneuver)
        {
            MovementStruct movementStruct = new MovementStruct
            {
                Speed           = maneuver.ManeuverSpeed,
                Bearing         = maneuver.Bearing,
                Direction       = maneuver.Direction,
                ColorComplexity = maneuver.ColorComplexity
            };

            if (IsForced)
            {
                if (!failedManeuvers.Contains(movementStruct))
                {
                    failedManeuvers.Add(movementStruct);
                }
            }

            MovementStruct alternativeMovementStruct = movementStruct;

            switch (maneuver.Bearing)
            {
            case ManeuverBearing.Straight:
                alternativeMovementStruct.Bearing = ManeuverBearing.Bank;

                alternativeMovementStruct.Direction = ManeuverDirection.Left;
                alternativeManeuvers.Add(GetSimilarManeuverByStruct(alternativeMovementStruct));

                alternativeMovementStruct.Direction = ManeuverDirection.Right;
                alternativeManeuvers.Add(GetSimilarManeuverByStruct(alternativeMovementStruct));
                break;

            case ManeuverBearing.Bank:
                alternativeMovementStruct.Bearing = ManeuverBearing.Turn;
                alternativeManeuvers.Add(GetSimilarManeuverByStruct(alternativeMovementStruct));

                alternativeMovementStruct.Bearing   = ManeuverBearing.Straight;
                alternativeMovementStruct.Direction = ManeuverDirection.Forward;
                alternativeManeuvers.Add(GetSimilarManeuverByStruct(alternativeMovementStruct));
                break;

            case ManeuverBearing.Turn:
                alternativeMovementStruct.Bearing = ManeuverBearing.Bank;
                alternativeManeuvers.Add(GetSimilarManeuverByStruct(alternativeMovementStruct));
                break;

            case ManeuverBearing.KoiogranTurn:
                alternativeMovementStruct.Bearing = ManeuverBearing.Bank;

                alternativeMovementStruct.Direction = ManeuverDirection.Left;
                alternativeManeuvers.Add(GetSimilarManeuverByStruct(alternativeMovementStruct));

                alternativeMovementStruct.Direction = ManeuverDirection.Right;
                alternativeManeuvers.Add(GetSimilarManeuverByStruct(alternativeMovementStruct));
                break;

            default:
                break;
            }

            return(alternativeManeuvers);
        }
Esempio n. 27
0
        public bool HasManeuver(MovementStruct maneuverStruct)
        {
            string maneuverString = maneuverStruct.ToString();

            return(HasManeuver(maneuverString));
        }