コード例 #1
0
 private void Awake()
 {
     aiPath                 = GetComponent <RichAI>();
     characterAnim          = GetComponent <CharacterAnimCpt>();
     rvoController          = GetComponent <RVOController>();
     rvoController.priority = Random.Range(0f, 1f);
 }
コード例 #2
0
 // Start is called before the first frame update
 void Awake()
 {
     mind         = GetComponent <CreatureMind>();
     goAi         = GetComponent <AIDestinationSetter>();
     wanderAI     = GetComponent <WanderingDestinationSetter>();
     ai           = GetComponent <RichAI>();
     maxSpeed     = ai.maxSpeed;
     nextDecision = Random.Range(0, brainTime);
     //testing!
     rb             = GetComponent <Rigidbody>();
     jumpTimeOffset = Random.Range(0, 9);
     text           = transform.GetChild(0).GetComponent <TextMesh>();
     text.text      = "";
     //test soundmaking
     sm      = GetComponent <SoundMaker>();
     ih      = gameObject.AddComponent <ItemHandler>();
     health  = gameObject.AddComponent <Health>();
     effects = new List <ParticleSystem>();
     chatLog = ChatLog.instance;
     foreach (Transform child in transform)
     {
         ParticleSystem s = child.GetComponent <ParticleSystem>();
         if (s)
         {
             effects.Add(s);
         }
     }
 }
コード例 #3
0
    // Use this for initialization
    void Start()
    {
        _mousFun = MouseFunctions.instance;
        if (_mousFun == null)
        {
            Debug.LogWarning("Mouse function not assign in scenes!!");
        }
        _mousFun.Right_Click_Once_Event   += _mousFun_Right_Click_Once_Event;
        _mousFun.Right_Double_Click_Event += _mousFun_Right_Double_Click_Event;
        _mousFun.Left_Click_Once_Event    += _mousFun_Left_Click_Once_Event;
        _mousFun.Left_Double_Click_Event  += _mousFun_Left_Double_Click_Event;

        _bt = GetComponent <BehaviorTree>();
        if (_bt == null)
        {
            Debug.LogWarning("No BehaviorTree attach!!!");
            return;
        }

        _CC = Camera_Controller.Instance;
        if (_CC == null)
        {
            Debug.LogWarning("No camera controller!!!");
        }
        _CC.Camera_Mode_Change_Event += _Camera_Mode_Changed;

        _RichAI = GetComponent <RichAI>();
        _AIPath = GetComponent <AIPath>();
    }
コード例 #4
0
    void Awake()
    {
        mRichAI            = GetComponent <RichAI>();
        mSquadData         = new SquadData();
        mUnitTransformList = new List <Transform>();
        mEnemySquadDic     = new Dictionary <int, SquadController>();

        InitAwake();

        mIdleState.mdGetInState  += SquadIdleGetInFunc;
        mIdleState.mdGetOutState += SquadIdleGetOutFunc;
        mIdleState.mdExcuteState += SquadIdleExcuteFunc;

        mWalkState.mdGetInState  += SquadWalkGetInFunc;
        mWalkState.mdExcuteState += SquadWalkExcuteFunc;
        mWalkState.mdGetOutState += SquadWalkGetOutFunc;

        mAttackState.mdGetInState  += SquadAttackGetInFunc;
        mAttackState.mdExcuteState += SquadAttackExcuteFunc;
        mAttackState.mdGetOutState += SquadAttackGetOutFunc;

        mPrepareState.mdGetInState  += SquadPrepareGetInFunc;
        mPrepareState.mdExcuteState += SquadPrepareExcuteFunc;
        mPrepareState.mdGetOutState += SquadPrepareGetOutFunc;

        mDieState.mdGetInState  += SquadDieGetInFunc;
        mDieState.mdExcuteState += SquadDieExcuteFunc;
        mDieState.mdGetOutState += SquadDieGetOutFunc;

        mStateMachine.StartWorking();
        EventManager.GetInstance().AddEventListener(EventId.SomeSquadDie, SomeSquadDie);
        EventManager.GetInstance().AddEventListener(EventId.ReSetPosition, ReSetPosition);
    }
コード例 #5
0
    void Awake()
    {
        richAI = GetComponent <RichAI>();
        seeker = GetComponent <Seeker>();
        aStar  = GetComponent <AstarPath>();

        player = GameObject.FindGameObjectWithTag("Player");
        //playerHealth = player.GetComponent<PlayerHealth>;
        //enemyHealth = GetComponenet<EnemyHealth>;
        anim        = transform.GetComponentInChildren <Animator>();
        guardSprite = transform.GetComponentInChildren <SpriteRenderer>();

        richAI.funnelSimplification = true;

        //GotoNextPoint();

        //navMeshAreas = NavMesh.CalculateTriangulation();
        //polygons = navMeshAreas.indices;
        //verticies = navMeshAreas.vertices;

        //Mesh mesh = sphere.GetComponent<MeshFilter>().mesh;
        //mesh.Clear();
        //mesh.vertices = verticies;
        //mesh.triangles = polygons;
    }
コード例 #6
0
 public ChaseTargetFromADistanceState(Transform target, RichAI richAI, AIDestinationSetter destinationSetter, Func <bool> stoppingStatement)
 {
     _target            = target;
     _richAI            = richAI;
     _destinationSetter = destinationSetter;
     _stoppingStatement = stoppingStatement;
 }
コード例 #7
0
 void OnEnable()
 {
     ai = GetComponent <RichAI>();
     if (ai != null)
     {
         ai.onTraverseOffMeshLink += TraverseOffMeshLink;
     }
 }
コード例 #8
0
 // Token: 0x06002A04 RID: 10756 RVA: 0x001C2A6B File Offset: 0x001C0C6B
 private void OnDisable()
 {
     if (this.ai != null)
     {
         RichAI richAI = this.ai;
         richAI.onTraverseOffMeshLink = (Func <RichSpecial, IEnumerator>)Delegate.Remove(richAI.onTraverseOffMeshLink, new Func <RichSpecial, IEnumerator>(this.TraverseOffMeshLink));
     }
 }
コード例 #9
0
 // Token: 0x06002A03 RID: 10755 RVA: 0x001C2A1C File Offset: 0x001C0C1C
 private void OnEnable()
 {
     this.ai = base.GetComponent <RichAI>();
     if (this.ai != null)
     {
         RichAI richAI = this.ai;
         richAI.onTraverseOffMeshLink = (Func <RichSpecial, IEnumerator>)Delegate.Combine(richAI.onTraverseOffMeshLink, new Func <RichSpecial, IEnumerator>(this.TraverseOffMeshLink));
     }
 }
コード例 #10
0
    protected override void Awake()
    {
        base.Awake();
        ai   = GetComponent <RichAI>();
        anim = GetComponent <Animator>();

        if (UseRigidBody)
        {
            body = GetComponentInChildren <Rigidbody>();
        }
    }
コード例 #11
0
    private void OnTriggerEnter(Collider other)
    {
        if (other.tag == "Enemy")
        {
            RichAI rAI = other.GetComponent <RichAI>();

            rAI.HomeRun();

            sound();

            Instantiate(_impactPrefab, transform.position, Camera.main.transform.rotation);
        }
    }
コード例 #12
0
    void Awake()
    {
        // agent = GetComponent<NavMeshAgent>();
        astarAgent = GetComponent <IAstarAI>();
        richAgent  = GetComponent <RichAI>();
        seeker     = GetComponent <Seeker>();

        fov             = GetComponent <FieldOfView>();
        stateController = GetComponent <StateController>();

        // agent.speed = speed;
        astarAgent.maxSpeed = speed;

        attackCycleReady = true;
    }
コード例 #13
0
        /// <summary>
        /// Пытается сменить цель, а также обновляет список пройденных чекпоинтов
        /// </summary>
        public static void TryChangeTarget(MonoBehaviour self, RichAI richaAI, Checkpoint checkPoint, List <Checkpoint> traversedCheckpoints)
        {
            if (!self.enabled)
            {
                return;
            }
            if (!traversedCheckpoints.Contains(checkPoint))
            {
                var target = RandomUtils.GetRandomWithoutExcludeds(checkPoint.NextCheckpoints, traversedCheckpoints.ToArray()).transform;
                if (target == null)
                {
                    Debug.LogError("next target not found in checkpoint", self);
                    return;
                }
                richaAI.target = target;

                traversedCheckpoints.Add(checkPoint);
            }
        }
コード例 #14
0
        void Awake()
        {
            AIBehaviors ai = GetComponent <AIBehaviors>();

            if (target == null)
            {
                target = new GameObject().transform;
            }

            richAI        = GetComponent <RichAI>();
            richAI.target = target;

            if (richAI == null)
            {
                Debug.LogError("You must add the 'RichAI' component to the Game Object '" + name + "' in order to use the Astar Pathfinding Project integration.");
                return;
            }

            richAI.target   = target;
            ai.externalMove = OnMove;
        }
コード例 #15
0
    // Use this for initialization
    void Awake()
    {
        mEnemyTrans = new List <Transform>();
        //mForceAttackList = new List<Transform>();
        mUnitData = new UnitData();

        mRVOController = transform.GetComponent <RVOController>();
        mRichAI        = transform.GetComponent <RichAI>();

        mThinkTime = mThinkTimeSpace;

        mUnitAnimation = GetComponentInChildren <Animation>();

        InitAwake();

        mIdleState.mdGetInState  += UnitIdleGetInFunc;
        mIdleState.mdGetOutState += UnitIdleGetOutFunc;
        mIdleState.mdExcuteState += UnitIdleExcuteFunc;

        mWalkState.mdGetInState  += UnitWalkGetInFunc;
        mWalkState.mdExcuteState += UnitWalkExcuteFunc;
        mWalkState.mdGetOutState += UnitWalkGetOutFunc;

        mAttackState.mdGetInState  += UnitAttackGetInFunc;
        mAttackState.mdExcuteState += UnitAttackExcuteFunc;
        mAttackState.mdGetOutState += UnitAttackGetOutFunc;

        mPrepareState.mdGetInState  += UnitPrepareGetInFunc;
        mPrepareState.mdExcuteState += UnitPrepareExcuteFunc;
        mPrepareState.mdGetOutState += UnitPrepareGetOutFunc;

        mDieState.mdGetInState  += UnitDieGetInFunc;
        mDieState.mdExcuteState += UnitDieExcuteFunc;
        mDieState.mdGetOutState += UnitDieGetOutFunc;

        mStateMachine.StartWorking();

        //the Event handlers
        SetUpEventHandlers();
    }
コード例 #16
0
    private void OnValidate()
    {
        if (_destinationSetter == null)
        {
            _destinationSetter = this.GetComponent <AIDestinationSetter>();
        }

        if (_richAI == null)
        {
            _richAI = this.GetComponent <RichAI>();
        }

        if (_turret == null)
        {
            _turret = this.GetComponentInChildren <ATurret>();
        }

        if (_seeker == null)
        {
            _seeker = this.GetComponentInChildren <Seeker>();
        }
    }
コード例 #17
0
 protected void Awake()
 {
     _ai         = GetComponent <RichAI>();
     _anim       = GetComponent <Animator>(); // Used to determine root motion
     _blackboard = GetComponent <Blackboard>();
 }