Beispiel #1
0
 // Update is called once per frame
 void Update()
 {
     if (moveEnabled)
     {
         if (pattern == ActionPattern.patrol)
         {
             Patrol();
             var max = GameManager.Instance.Player.AntsInstancesCount;
             for (int i = 0; i < max; i++)
             {
                 var ant = GameManager.Instance.Player.AntInstancesAt(i);
                 DetectAnt(ant);
             }
             Rotate(patrol[patNum]);
         }
         else if (pattern == ActionPattern.attack)
         {
             Chase(chaseAnt.transform);
             Rotate(chaseAnt);
         }
     }
     if (DistancePlayer(player.transform) <= playerDistance)
     {
         pattern = ActionPattern.patrol;
     }
 }
Beispiel #2
0
 public Step(ActionPattern pattern, GameObject source, Coordinates sourceP, Coordinates targetP)
 {
     this.pattern = pattern;
     this.source  = source;
     this.sourceP = sourceP;
     this.targetP = targetP;
 }
Beispiel #3
0
 public NormalState(EnemyInformation Info) : base(Info)
 {
     enemyAction = ActionPattern.LOOK;
     nextState   = this;
     enemyInfo.animator.SetFloat("speed", 0f);
     enemyInfo.animator.Play("Idle");
     targetPosition = enemyInfo.transform.position;
 }
Beispiel #4
0
 //アリの検知
 protected void DetectAnt(Player.Ant ant)
 {
     if (ViewingAngle(ant.transform) >= detectCorner && DistanceAnt(ant.transform) < detectDistance)
     {
         pattern  = ActionPattern.attack;
         chaseAnt = ant.gameObject;
     }
 }
Beispiel #5
0
    //アリを食べる
    IEnumerator AttackTimer(GameObject eatenAnt)
    {
        moveEnabled = false;
        eatenAnt.GetComponent <Player.Ant>().Death();
        pattern = ActionPattern.patrol;
        yield return(new WaitForSeconds(waitTime));

        moveEnabled = true;
    }
Beispiel #6
0
    IEnumerator ExecuteActionPattern(ActionPattern actionPattern, int currentActionindex)
    {
        if (currentActionindex < actionPattern.Actions.Count)
        {
            TriggerAction(actionPattern.Actions[currentActionindex]);
            yield return(new WaitForSeconds((float)
                                            actionPattern.Actions[currentActionindex].TimeToComplete));

            //  DrivesHandler();

            StartCoroutine(ExecuteActionPattern(actionPattern, currentActionindex + 1));
        }
        else
        {
            yield return(new WaitForSeconds(0));
        }
    }
Beispiel #7
0
 public OnDemandCommand(SkillEntity skillEntity, bool preCooltime, FireCondition condition)
     : base(skillEntity, preCooltime, condition)
 {
     pattern = ActionPattern.Create(actionPattern);
 }
Beispiel #8
0
 public OnDemandCommand(string animationName, string actionPattern, int priority, float cooltime, bool preCooltime, FireCondition condition)
     : base(animationName, actionPattern, priority, cooltime, 0, preCooltime, condition)
 {
     pattern = ActionPattern.Create(actionPattern);
 }
Beispiel #9
0
    public static bool IsValid(string text)
    {
        if (TryRemoveCommentBlock(ref text))
        {
            text = StringTool.RemoveWhiteSpace(text);
            text = RemoveTailSplit(text);

            if (!string.IsNullOrEmpty(text))
            {
                try
                {
                    ActionPattern actionPattern = new ActionPattern(text);
                    if (actionPattern != null && actionPattern.patternType == ActionPatternType.Delegate)
                    {
                        return IsValid(actionPattern.strValue);
                    }
                }
                catch
                {
                    return false;
                }
            }
            return true;
        }
        return false;
    }
Beispiel #10
0
 private void ActionPatternHandler(ActionPattern actionPattern)
 {
     ABOD3_Bridge.GetInstance().AletForElement(botNumber, actionPattern.Name, "AP");
     StartCoroutine(ExecuteActionPattern(actionPattern, 0));
 }
Beispiel #11
0
 public Attack(ActionPattern pattern, Coordinates sourceP, string message)
 {
     this.pattern = pattern;
     this.sourceP = sourceP;
     this.message = message;
 }
Beispiel #12
0
 /// <summary>
 /// 起点となるNPC、アビリティからそのターンの行動リストを生成する
 /// </summary>
 /// <param name="states">現在のゲーム状態</param>
 /// <param name="action">起点となる行動内容</param>
 /// <returns>ターン内行動リスト</returns>
 static List <Happened> GenerateHappenedList(this GameStates states, ActionPattern action)
 {
     throw new NotImplementedException();
 }
Beispiel #13
0
        private Vector3 Action()
        {
            Vector3 lookVector = (enemyInfo.player.transform.position - enemyInfo.transform.position).normalized;

            lookVector.y = 0;
            enemyInfo.transform.rotation = Quaternion.LookRotation(lookVector);
            Vector3 moveDirection = Vector3.zero;

            float dis = (enemyInfo.player.transform.position - enemyInfo.transform.position).magnitude;

            switch (enemyAction)
            {
            case    ActionPattern.LOOK:
                enemyInfo.animator.SetFloat("speed", 0);
                if (dis > ACTIVE_RANGE)
                {
                    return(Vector3.zero);
                }

                if (Time.time - timeCounter > WAIT_TIME)
                {
                    if (dis > WAIN_RANGE * 2f)
                    {
                        int rand = Random.Range(1, 10);
                        if (rand > 8)
                        {
                            enemyAction = ActionPattern.WALK_LEFT;
                        }

                        timeCounter = Time.time;
                    }
                    else
                    {
                        int rand = Random.Range(1, 10);

                        if (rand > 3)
                        {
                            enemyAction = ActionPattern.WALK_LEFT;
                        }
                        else
                        {
                            if (dis < enemyInfo.range)
                            {
                                enemyAction = ActionPattern.ATTACK;
                                enemyInfo.animator.CrossFade("Attack", 0.1f);
                            }
                            else
                            {
                                enemyAction = ActionPattern.WALK_FRONT;
                            }
                        }

                        timeCounter = Time.time;
                    }
                }
                break;

            case    ActionPattern.ATTACK:
                if (Time.time - timeCounter > WAIT_TIME)
                {
                    enemyAction = ActionPattern.LOOK;
                    timeCounter = Time.time + WAIT_TIME * 2f;
                }
                break;

            case    ActionPattern.WALK_LEFT:
                moveDirection   = enemyInfo.transform.TransformDirection(Vector3.left);
                moveDirection.y = 0f;
                moveDirection   = moveDirection.normalized;

                speed = enemyInfo.moveSpeed / 2f;
                enemyInfo.animator.SetFloat("speed", 0.5f);
                if (Time.time - timeCounter > WAIT_TIME / 3 + Random.Range(0.1f, 0.5f))
                {
                    if (GetDistance() > WAIN_RANGE)
                    {
                        enemyAction = ActionPattern.WALK_RIGHT;
                        timeCounter = Time.time;
                    }
                    else
                    {
                        int rand = Random.Range(0, 10);

                        if (rand > 5)
                        {
                            enemyAction = ActionPattern.WALK_RIGHT;
                        }
                        else
                        {
                            enemyAction = ActionPattern.LOOK;
                        }

                        timeCounter = Time.time;
                    }
                }
                break;

            case    ActionPattern.WALK_RIGHT:
                moveDirection   = enemyInfo.transform.TransformDirection(Vector3.right);
                moveDirection.y = 0f;
                moveDirection   = moveDirection.normalized;

                speed = enemyInfo.moveSpeed / 2f;
                enemyInfo.animator.SetFloat("speed", 0.5f);
                if (Time.time - timeCounter > WAIT_TIME / 3 + Random.Range(0.1f, 0.5f))
                {
                    enemyAction = ActionPattern.LOOK;
                    timeCounter = Time.time + WAIT_TIME;
                }
                break;

            case    ActionPattern.WALK_FRONT:
                moveDirection   = enemyInfo.transform.TransformDirection(Vector3.forward);
                moveDirection.y = 0f;
                moveDirection   = moveDirection.normalized;

                speed = enemyInfo.moveSpeed / 2f;
                enemyInfo.animator.SetFloat("speed", 0.5f);
                if (Time.time - timeCounter > WAIT_TIME / 2 + Random.Range(0.1f, 0.5f))
                {
                    int rand = Random.Range(0, 10);

                    if (rand > 6)
                    {
                        enemyAction = ActionPattern.LOOK;
                    }
                    else
                    {
                        enemyAction = ActionPattern.WALK_BACK;
                    }
                    timeCounter = Time.time;
                }
                break;

            case    ActionPattern.WALK_BACK:
                moveDirection   = enemyInfo.transform.TransformDirection(Vector3.back);
                moveDirection.y = 0f;
                moveDirection   = moveDirection.normalized;

                speed = enemyInfo.moveSpeed / 2f;
                enemyInfo.animator.SetFloat("speed", 0.5f);
                if (Time.time - timeCounter > WAIT_TIME / 3 + Random.Range(0.1f, 0.5f))
                {
                    enemyAction = ActionPattern.LOOK;
                    timeCounter = Time.time;
                }
                break;
            }

            return(moveDirection);
        }
Beispiel #14
0
 public NormalState()
 {
     enemyAction = ActionPattern.LOOK;
     nextState   = this;
 }