コード例 #1
0
        public override void Execute(EnemyController enemyController)
        {
            PatrolController patrolController = (PatrolController)enemyController;

            if (!_currentState.checkValid(patrolController) || _isFinished)
            {
                // randomly change current state
                int randomStateCase;
                do
                {
                    randomStateCase = UnityEngine.Random.Range(0, 3);
                } while (randomStateCase == _currentStateCase);

                _currentStateCase = randomStateCase;
                switch (_currentStateCase)
                {
                case 0:
                    _currentState = new Idle();
                    break;

                case 1:
                    _currentState = new WalkingLeft();
                    break;

                case 2:
                    _currentState = new WalkingRight();
                    break;
                }

                patrolController.StartCoroutine(executeCoroutine(patrolController.behaveInterval()));
            }

            _currentState.Execute(patrolController);
        }
コード例 #2
0
        public override void Execute(EnemyController enemyController)
        {
            PatrolController patrolController = (PatrolController)enemyController;
            float            dist             = patrolController.playerEnemyDistance();

            patrolController.walk(Math.Abs(dist) < 0.1f ? 0 : dist);
        }
コード例 #3
0
        private void AttackThief()
        {
            DeathmatchAgent  agent            = GetComponentInParent <DeathmatchAgent>();
            PatrolController patrolController = GetComponentInParent <PatrolController>();

            agent.TrackLayerAndTag(m_InteractorGameObject.layer, m_InteractorGameObject.tag);
            patrolController.CheckAlarm(m_InteractorGameObject);
        }
コード例 #4
0
 void Awake()
 {
     rigidBody        = GetComponent <Rigidbody2D>();
     circleCollider2D = GetComponent <CircleCollider2D>();
     patrolController = GetComponent <PatrolController>();
     spriteRenderer   = GetComponent <SpriteRenderer>();
     audioSource      = GetComponent <AudioSource>();
     animator         = GetComponent <Animator>();
     soulPrefab       = Resources.Load("Prefabs/Soul");
 }
コード例 #5
0
 public void Alarm(float radius)
 {
     Collider[] hitColliders = Physics.OverlapSphere(transform.position, radius, layerMask.value);
     foreach (Collider collider in hitColliders)
     {
         PatrolController controller = collider.GetComponent <PatrolController>();
         if (controller != null)
         {
             controller.CheckAlarm(gameObject);
         }
     }
 }
コード例 #6
0
    public MiteEnemyController(MiteEnemy e) : base(e)
    {
        this.enemy            = e;
        this.enemyAnimator    = e.GetComponentInChildren <Animator>();
        this.transform        = e.transform;
        this.rb               = e.GetComponent <Rigidbody2D>();
        this.patrolController = e.GetComponent <PatrolController>();

        this.playerTransform  = PlayerManager.instance.playerObject.transform;
        this.playerCharacter  = PlayerManager.instance.playerCharacter;
        this.playerDamageable = this.playerTransform.GetComponent <IDamageableEntity>();
    }
コード例 #7
0
        void Start()
        {
            if (flowchart == null && flowchartName != null && flowchartName.Trim().Length != 0)
            {
                flowchart = GameObject.Find(flowchartName).GetComponent <Fungus.Flowchart>();
            }

            patrolController = GetComponentInParent <PatrolController>();
            health           = GetComponentInParent <CustomHealth>();
            behaviorTree     = GetComponentInParent <BehaviorTree>();
            navMeshAgent     = GetComponentInParent <NavMeshAgent>();
            deathmatchAgent  = GetComponentInParent <DeathmatchAgent>();
        }
コード例 #8
0
ファイル: ChangeOfScenery.cs プロジェクト: raevskiy/Polygon
        private void Teleport(GameObject character, GameObject teleport)
        {
            PatrolController patrolController = character.GetComponent <PatrolController>();

            if (patrolController != null && patrolController.enabled)
            {
                patrolController.TeleportToWaypoint(teleport);
            }
            else
            {
                character.transform.position = teleport.transform.position;
                character.transform.rotation = teleport.transform.rotation;
            }
        }
コード例 #9
0
    public override void OnInspectorGUI()
    {
        PatrolController script = (PatrolController)target;

        DrawDefaultInspector();

        if (GUILayout.Button("Reset"))
        {
            Undo.RecordObject(script, "Reset point");

            script.points.Clear();

            Vector2 pos = script.transform.position;

            script.points.Add(pos + Vector2.right * 1f);
            script.points.Add(pos - Vector2.right * 1f);
        }
    }
コード例 #10
0
    protected virtual void OnSceneGUI()
    {
        PatrolController script = (PatrolController)target;

        for (int i = 0; i < script.points.Count; i++)
        {
            EditorGUI.BeginChangeCheck();

            Vector2 newPoint = Handles.PositionHandle(script.points[i], Quaternion.identity);

            if (EditorGUI.EndChangeCheck())
            {
                Undo.RecordObject(script, "Change point");

                script.points[i] = newPoint;
                script.OnValidate();
            }
        }
    }
コード例 #11
0
    private void Awake()
    {
        rb            = GetComponent <Rigidbody2D>();
        originalAngle = rb.transform.rotation;

        los_rb = lineOfSight.GetComponent <Rigidbody2D>();

        playerRb  = player.GetComponent <Rigidbody2D>();
        playerCol = player.GetComponent <CircleCollider2D>();
        playerMov = player.GetComponent <PlayerMovement>();

        destinationSetter = GetComponent <AIDestinationSetter>();

        pathfinding = GetComponent <AIPath>();

        audioMgr = GameObject.Find("AudioManager").GetComponent <AudioManager>();

        patrol = GetComponent <PatrolController>();

        anim = gfx.GetComponent <Animator>();
    }
コード例 #12
0
 void Awake()
 {
     patrolController = transform.parent.GetComponent <PatrolController>();
 }
コード例 #13
0
 public override void Execute(PatrolController patrolController)
 {
     patrolController.walk(1);
 }
コード例 #14
0
 public override bool checkValid(PatrolController patrolController)
 {
     return(patrolController.reachEdge() != 1);
 }
コード例 #15
0
 public abstract void Execute(PatrolController enemyController);
コード例 #16
0
 public abstract bool checkValid(PatrolController enemyController);