示例#1
0
 void EditAlternateBehaviorData(AlternateBehaviorData alternateBehaviorData)
 {
     EditorGUILayout.LabelField("--------------------------- Edit AlternateBehaviorData: " + alternateBehaviorData.Name);
     alternateBehaviorData.priority = EditorGUILayout.IntField(new GUIContent("Priority (0=least priority):", ""), alternateBehaviorData.priority);
     string[] allBehaviorName = aiEditor.AI.Behaviors.Select(x => x.Name).ToArray();
     alternateBehaviorData.NextBehaviorName = EditorCommon.EditPopup("Next beahvior:",
                                                                     alternateBehaviorData.NextBehaviorName,
                                                                     allBehaviorName);
     EditConditionWrapper(alternateBehaviorData.AlternateCondition);
 }
示例#2
0
    public virtual void EditBaseAIProperty(AI AI)
    {
        EditorGUILayout.LabelField(new GUIContent("------------- AI Base property", ""));
        AI.Name           = EditorGUILayout.TextField(new GUIContent("AI Name", "Name of this AI component."), AI.Name);
        AI.Description    = EditorGUILayout.TextField(new GUIContent("AI Description", "Description:."), AI.Description);
        AI.OffensiveRange = EditorGUILayout.FloatField(new GUIContent("AI Offensive range", "当敌人进入Offsensive range, AI会主动发起进攻."), AI.OffensiveRange);
        AI.DetectiveRange = EditorGUILayout.FloatField(new GUIContent("AI Detective range", "当敌人进入Detective range, AI会监测到这个敌人.DetectiveRange应该大于Offensive Range."), AI.DetectiveRange);
        AI.DetectiveRange = AI.DetectiveRange >= AI.OffensiveRange ? AI.DetectiveRange : AI.OffensiveRange;
        EditorGUILayout.BeginHorizontal();
        GUILayout.Label(new GUIContent("Attack Obstacle:", "攻击障碍物层,如果目标和AI之间存在该层的碰撞器,则AI无法攻击到目标."));
        AI.AttackObstacle = EditorGUILayoutx.LayerMaskField("", AI.AttackObstacle);
        EditorGUILayout.EndHorizontal();
//		AI.AlterBehaviorInterval = EditorGUILayout.FloatField (new GUIContent ("Behavior alternation time",
//            "Interval to alter behavior."), AI.AlterBehaviorInterval);

        AIBehavior[] AIBehaviors = this.AI.Behaviors;
        this.AI.FirstBehavior = EditorCommon.EditPopup("First Behavior:", this.AI.FirstBehavior, AIBehaviors.Select(x => x.Name).ToArray());
    }
示例#3
0
 public static PredatorPlayerJumpData EditJumpData(GameObject gameObject, PredatorPlayerJumpData jumpData)
 {
     jumpData.Name                  = EditorGUILayout.TextField("Name:", jumpData.Name);
     jumpData.JumpForwardTime       = EditorGUILayout.FloatField("Jump forward time", jumpData.JumpForwardTime);
     jumpData.JumpForwardSpeed      = EditorGUILayout.FloatField("Jump forward speed", jumpData.JumpForwardSpeed);
     jumpData.JumpOverSpeed         = EditorGUILayout.FloatField("Jump over speed", jumpData.JumpOverSpeed);
     jumpData.JumpOverCheckDistance = EditorGUILayout.FloatField("Jump over obstacle test distance", jumpData.JumpOverCheckDistance);
     jumpData.ObstacleToJumpOver    = EditorGUILayoutx.LayerMaskField("Jump over obstacle layer:", jumpData.ObstacleToJumpOver);
     jumpData.AnimationLayer        = EditorGUILayout.IntField("Jump animation layer:", jumpData.AnimationLayer);
     jumpData.PreJumpAnimation      = EditorCommon.EditPopup("PreJump Animation",
                                                             jumpData.PreJumpAnimation,
                                                             EditorCommon.GetAnimationNames(gameObject));
     jumpData.JumpingAnimation = EditorCommon.EditPopup("Jumping Animation",
                                                        jumpData.JumpingAnimation,
                                                        EditorCommon.GetAnimationNames(gameObject));
     jumpData.GroundingAnimation = EditorCommon.EditPopup("Grounding Animation",
                                                          jumpData.GroundingAnimation,
                                                          EditorCommon.GetAnimationNames(gameObject));
     return(jumpData);
 }
示例#4
0
    public virtual void EditBooleanConditionData(AtomConditionData ConditionData)
    {
        EditorGUILayout.BeginHorizontal();
        ConditionData.BooleanCondition = (AIBooleanConditionEnum)EditorGUILayout.EnumPopup(ConditionData.BooleanCondition);
        ConditionData.BooleanOperator  = (BooleanComparisionOperator)EditorGUILayout.EnumPopup(ConditionData.BooleanOperator);
        switch (ConditionData.BooleanCondition)
        {
        case AIBooleanConditionEnum.AlwaysTrue:
            break;

        case AIBooleanConditionEnum.CurrentTargetInLayer:
            ConditionData.LayerMaskForComparision = EditorGUILayoutx.LayerMaskField("Current target in layermask:", ConditionData.LayerMaskForComparision);
            break;

        case AIBooleanConditionEnum.EnemyInDetectiveRange:
            break;

        case AIBooleanConditionEnum.EnemyInOffensiveRange:
            break;

        case AIBooleanConditionEnum.InArea:
            ConditionData.CheckArea = (Collider)EditorGUILayout.ObjectField("Check against collider:", ConditionData.CheckArea, typeof(Collider));
            break;

        case AIBooleanConditionEnum.LatestBehaviorNameIs:
            string[] AllBehaviorName = AI.Behaviors.Select(x => x.Name).ToArray();
            ConditionData.StringValue = EditorCommon.EditPopup("behavior name:", ConditionData.StringValue
                                                               , AllBehaviorName);
            break;

        case AIBooleanConditionEnum.LastestBehaviorNameIsOneOf:
            AllBehaviorName = AI.Behaviors.Select(x => x.Name).ToArray();
            EditorGUILayout.BeginVertical();
            ConditionData.StringValueArray = EditorCommon.EditStringArray("behavior name:", ConditionData.StringValueArray
                                                                          , AllBehaviorName);
            EditorGUILayout.EndVertical();
            break;
        }
        EditorGUILayout.EndHorizontal();
    }
示例#5
0
    public virtual void EditCompositeConditionEntity(string Label, ConditionEntity entity,
                                                     CompositeConditionWrapper compositionConditionWrapper)
    {
        EditorGUILayout.LabelField(Label);
        entity.EntityType = (ConditionEntityType)EditorGUILayout.EnumPopup(new GUIContent("Entity type ", ""), entity.EntityType);
        string label = "";

        switch (entity.EntityType)
        {
        case ConditionEntityType.AtomCondition:
            label = "Choose one of atom condition id:";
            entity.EntityReferenceId = EditorCommon.EditPopup(label,
                                                              entity.EntityReferenceId,
                                                              compositionConditionWrapper.atomConditionDataArray.Select(x => x.Id).ToArray());
            break;

        case ConditionEntityType.ReferenceToComposite:
            label = "Choose one of composite condition id:";
            entity.EntityReferenceId = EditorCommon.EditPopup(label,
                                                              entity.EntityReferenceId,
                                                              compositionConditionWrapper.CompositeConditionArray.Select(x => x.Id).ToArray());
            break;
        }
    }
示例#6
0
    public void EditUnit()
    {
        if (AI.Unit == null)
        {
            AI.Unit = AI.GetComponent <Unit> ();
        }

        #region Edit Unit
        EnableEditUnit = EditorGUILayout.BeginToggleGroup("Edit Unit : " + AI.Unit.Name, EnableEditUnit);
        if (EnableEditUnit)
        {
            //EditBasicUnitProperty ();
            AI.Unit = (Unit)EditorCommon.EditBasicUnitProperty(AI.Unit);
            //Edit Start AI
            AbstractAI[] AllAI = AI.gameObject.GetComponents <AbstractAI> ();
            AI.Unit.StartAIName = EditorCommon.EditPopup("Unit Start AI:", AI.Unit.StartAIName, AllAI.Select(x => x.Name).ToArray());
            //Edit Idle Data
            if (EnableEditIdleData = EditorGUILayout.BeginToggleGroup("---Edit Idle Data", EnableEditIdleData))
            {
                AI.Unit.IdleData = EditorCommon.EditIdleDataArray(AI.Unit.gameObject,
                                                                  AI.Unit.IdleData);
            }
            EditorGUILayout.EndToggleGroup();

            //Edit rotate data
            if (EnableEditRotateData = EditorGUILayout.BeginToggleGroup("---Edit Rotate Data", EnableEditRotateData))
            {
                AI.Unit.RotateData = EditorCommon.EditRotateDataArray(AI.Unit.gameObject,
                                                                      AI.Unit.RotateData);
            }
            EditorGUILayout.EndToggleGroup();

            //Edit Move Data
            if (EnableEditMoveData = EditorGUILayout.BeginToggleGroup("---Edit Move Data", EnableEditMoveData))
            {
                AI.Unit.MoveData = EditorCommon.EditMoveDataArray(AI.Unit.gameObject,
                                                                  AI.Unit.MoveData);
            }
            EditorGUILayout.EndToggleGroup();

            //Edit attack data
            if (EnableEditAttackData = EditorGUILayout.BeginToggleGroup("---Edit Attack Data---", EnableEditAttackData))
            {
                AI.Unit.AttackData = EditorCommon.EditAttackDataArray(AI.Unit,
                                                                      AI.Unit.AttackData);
            }
            EditorGUILayout.EndToggleGroup();



            //Edit Effect Data
            if (EnableEditEffectData = EditorGUILayout.BeginToggleGroup("---Edit Effect Data---", EnableEditEffectData))
            {
                AI.Unit.EffectData = EditorCommon.EditEffectData(AI.Unit.EffectData);
            }
            EditorGUILayout.EndToggleGroup();

            //Edit Decal data
            if (EnableEditDecalData = EditorGUILayout.BeginToggleGroup("---Edit Decal Data---", EnableEditDecalData))
            {
                AI.Unit.DecalData = EditorCommon.EditDecalData(AI.Unit.DecalData);
            }
            EditorGUILayout.EndToggleGroup();
            //Edit receive damage data:
            if (EnableEditReceiveDamageData = EditorGUILayout.BeginToggleGroup("---Edit ReceiveDamage Data---", EnableEditReceiveDamageData))
            {
                AI.Unit.ReceiveDamageData = EditorCommon.EditReceiveDamageData(AI.Unit,
                                                                               AI.Unit.ReceiveDamageData);
            }
            EditorGUILayout.EndToggleGroup();


            //Edit death data
            if (EnableEditDeathData = EditorGUILayout.BeginToggleGroup("---Edit Death Data---", EnableEditDeathData))
            {
                AI.Unit.DeathData = EditorCommon.EditDeathData(AI.Unit, AI.Unit.DeathData);
            }
            EditorGUILayout.EndToggleGroup();

            //Edit audio data
            if (EnableEditAudioData = EditorGUILayout.BeginToggleGroup("---Edit Audio Data---", EnableEditAudioData))
            {
                AI.Unit.AudioData = EditorCommon.EditAudioData(AI.Unit, AI.Unit.AudioData);
            }
            EditorGUILayout.EndToggleGroup();
        }
        EditorGUILayout.EndToggleGroup();
        #endregion
    }
示例#7
0
    public virtual void EditAIBehaviorData(AIBehavior behavior)
    {
        string[] IdleDataNameArray      = this.AI.Unit.IdleData.Select(x => x.Name).ToArray <string> ();
        string[] AttackDataNameArray    = this.AI.Unit.AttackData.Select(x => x.Name).ToArray <string> ();
        string[] MoveDataNameArray      = this.AI.Unit.MoveData.Select(x => x.Name).ToArray <string> ();
        string[] SceneWaypointNameArray = Object.FindObjectsOfType(typeof(WayPoint)).Select(x => x.name).ToArray();
        SceneWaypointNameArray.OrderBy(x => x.ToString());

        int idx = 0;

        switch (behavior.Type)
        {
        case AIBehaviorType.Idle:
            if (IdleDataNameArray == null || IdleDataNameArray.Length == 0)
            {
                EditorGUILayout.LabelField("!!!There is no Idle Data defined in this Unit!!!");
            }
            else
            {
                idx = IndexOfArray <string> (IdleDataNameArray, behavior.IdleDataName);
                idx = EditorGUILayout.Popup("Use Idle data:", idx, IdleDataNameArray);
                behavior.IdleDataName = IdleDataNameArray [idx];
            }
            break;

        case AIBehaviorType.MoveToTransform:
            if (MoveDataNameArray == null || MoveDataNameArray.Length == 0)
            {
                EditorGUILayout.LabelField("!!!There is no Move Data defined in this Unit!!!");
            }
            else
            {
                idx = IndexOfArray <string> (MoveDataNameArray, behavior.MoveDataName);
                idx = EditorGUILayout.Popup("Use Move data:", idx, MoveDataNameArray);
                behavior.MoveDataName = MoveDataNameArray [idx];
                behavior.MoveToTarget = (Transform)EditorGUILayout.ObjectField(new GUIContent("Move to target", ""),
                                                                               behavior.MoveToTarget, typeof(Transform));
            }
            break;

        case AIBehaviorType.MoveAtDirection:
            if (MoveDataNameArray == null || MoveDataNameArray.Length == 0)
            {
                EditorGUILayout.LabelField("!!!There is no Move Data defined in this Unit!!!");
            }
            else
            {
                idx = IndexOfArray <string> (MoveDataNameArray, behavior.MoveDataName);
                idx = EditorGUILayout.Popup("Use Move data:", idx, MoveDataNameArray);
                behavior.MoveDataName     = MoveDataNameArray [idx];
                behavior.MoveDirection    = EditorGUILayout.Vector3Field("Move at direction", behavior.MoveDirection);
                behavior.IsWorldDirection = EditorGUILayout.Toggle(new GUIContent("Is world direction?", "Move at Direction 指定的方向,是世界方向还是局部方向?"), behavior.IsWorldDirection);
            }
            break;

        case AIBehaviorType.MoveToCurrentTarget:
            if (MoveDataNameArray == null || MoveDataNameArray.Length == 0)
            {
                EditorGUILayout.LabelField("!!!There is no Move Data defined in this Unit!!!");
            }
            else
            {
                idx = IndexOfArray <string> (MoveDataNameArray, behavior.MoveDataName);
                idx = EditorGUILayout.Popup("Use Move data:", idx, MoveDataNameArray);
                behavior.MoveDataName = MoveDataNameArray [idx];
            }
            break;

        case AIBehaviorType.Attack:
        case AIBehaviorType.AttackToPosition:
        case AIBehaviorType.AttackToDirection:
        case AIBehaviorType.HoldPosition:
            if (AttackDataNameArray == null || AttackDataNameArray.Length == 0)
            {
                EditorGUILayout.LabelField("!!!There is no Attack Data defined in this Unit!!!");
                return;
            }
            if (MoveDataNameArray == null || MoveDataNameArray.Length == 0)
            {
                EditorGUILayout.LabelField("!!!There is no Move Data defined in this Unit!!!");
                return;
            }

            //Attack Data:
            behavior.UseRandomAttackData = EditorGUILayout.Toggle(new GUIContent("Use random attack data", ""), behavior.UseRandomAttackData);
            if (behavior.UseRandomAttackData)
            {
                behavior.AttackDataNameArray = EditorCommon.EditStringArray("Attack data:", behavior.AttackDataNameArray, AttackDataNameArray);
            }
            else
            {
                behavior.AttackDataName = EditorCommon.EditPopup("Attack data:", behavior.AttackDataName, AttackDataNameArray);
            }
            // Move data:
            idx = IndexOfArray <string> (MoveDataNameArray, behavior.MoveDataName);
            idx = EditorGUILayout.Popup("Move data:", idx, MoveDataNameArray);
            behavior.MoveDataName = MoveDataNameArray [idx];

            if (behavior.Type == AIBehaviorType.AttackToPosition)
            {
                behavior.MoveToTarget = (Transform)EditorGUILayout.ObjectField(new GUIContent("Move to target", ""),
                                                                               behavior.MoveToTarget, typeof(Transform));
            }
            if (behavior.Type == AIBehaviorType.AttackToDirection)
            {
                behavior.MoveDirection    = EditorGUILayout.Vector3Field("Move at direction", behavior.MoveDirection);
                behavior.IsWorldDirection = EditorGUILayout.Toggle(new GUIContent("Is world direction?", "Move at Direction in world space or local space?"), behavior.IsWorldDirection);
            }
            if (behavior.Type == AIBehaviorType.HoldPosition)
            {
                behavior.HoldRadius = EditorGUILayout.FloatField(new GUIContent("Hold Position:", "The position transform."), behavior.HoldRadius);
            }

            //Idle data:
            behavior.AttackInterrupt = EditorGUILayout.Toggle("Attack interrupt:", behavior.AttackInterrupt);
            if (behavior.AttackInterrupt)
            {
                behavior.IdleDataName      = EditorCommon.EditPopup("Interval Idle data:", behavior.IdleDataName, IdleDataNameArray);
                behavior.AttackIntervalMin = EditorGUILayout.FloatField("Min attack interval:", behavior.AttackIntervalMin);
                behavior.AttackIntervalMax = EditorGUILayout.FloatField("Max attack interval:", behavior.AttackIntervalMax);
            }
            break;

        case AIBehaviorType.SwitchToAI:
            AbstractAI[] AllAI = this.AI.Unit.GetComponents <AbstractAI> ();
            behavior.SwitchToAIName = EditorCommon.EditStringArray("Switch to next AI:", behavior.SwitchToAIName, AllAI.Select(x => x.Name).ToArray());
            break;

        case AIBehaviorType.MoveToWaypoint:
            // Move data:
            idx = IndexOfArray <string> (MoveDataNameArray, behavior.MoveDataName);
            idx = EditorGUILayout.Popup("Move data:", idx, MoveDataNameArray);
            behavior.MoveDataName  = MoveDataNameArray [idx];
            behavior.WaypointNames = EditorCommon.EditStringArray("Select scene waypoint:", behavior.WaypointNames, SceneWaypointNameArray);
            break;
        }
    }