Esempio n. 1
0
    /// <summary>
    /// 遊走狀態檢測,檢測敵人距離及遊走是否越界
    /// </summary>
    void WanderRadiusCheck()
    {
        distanceToPlayer     = Vector2.Distance(transform.position, playerUnit.transform.position);
        distanceToInitial    = Vector2.Distance(transform.position, initialPosition);
        distanceToStartPoint = Vector2.Distance(transform.position, startPosition);

        if (distanceToPlayer < attackRange)
        {
            is_Walking   = false;
            currentState = MonsterState.ATTACK;
        }
        else if (distanceToPlayer < defendRadius)
        {
            is_Walking   = false;
            currentState = MonsterState.CHASE;
        }
        else if (distanceToPlayer < alertRadius)
        {
            is_Walking   = false;
            currentState = MonsterState.WARN;
        }

        if (distanceToStartPoint > wanderRadius)        // 一次不給走太遠距離
        {
            enemy3D.GetComponent <AgentScript>().MoveAgent(transform.position, 1f);
            is_Walking = false;
        }
    }
Esempio n. 2
0
        public int HandleMonsterCollision(int mode, int hitPoints)
        {
            /* Modes:
             * 0 - for spells different than shield
             * 1 - for shield spell
             */
            switch (mode)
            {
            case 0:
                monsterState = MonsterState.Hurt;
                activeMonster.GetHurt(hitPoints);
                break;

            case 1:
                isWizardShieldActive = true;
                break;
            }

            if (activeMonster.EndOfLife)
            {
                return(activeMonster.ExpereinceForPlayer);
            }
            else
            {
                return(0);
            }
        }
 void UpdateWaypoint()
 {
     if (waypoints.Length > 0)
     {
         if (Random.Range(1, 100) >= 100 - idlePercentChance)
         {
             currentState = MonsterState.Idling;
         }
         else
         {
             if (waypoints.Length <= waypointIndex + 1)
             {
                 waypointIndex   = 0;
                 currentWaypoint = waypoints[0];
             }
             else
             {
                 waypointIndex  += 1;
                 currentWaypoint = waypoints[waypointIndex];
             }
             FaceTarget(currentWaypoint);
             agent.SetDestination(currentWaypoint.position);
         }
     }
 }
Esempio n. 4
0
    //怪兽死亡时处理例程
    void MonsterDie()
    {
        //将死亡的怪兽tag设置为untagged
        gameObject.tag = "Untagged";
        //停止所有协程

        StopAllCoroutines();

        isDie        = true;
        monsterState = MonsterState.die;
        nvAgent.Stop();
        animator.SetTrigger("IsDie");

        //禁用怪兽的collider
        gameObject.GetComponentInChildren <CapsuleCollider> ().enabled = false;

        foreach (Collider coll in gameObject.GetComponentsInChildren <SphereCollider>())
        {
            coll.enabled = false;
        }

        //调用GameUI脚本的处理分数累加与显示的函数
        gameUI.DispScore(50);

        //调用将怪兽放回对象池的协程函数
        StartCoroutine(this.PushObjectPool());
    }
Esempio n. 5
0
        /// <summary>
        /// 根据权重随机待机指令
        /// </summary>
        void RandomAction()
        {
            //更新行动时间
            lastActTime = Time.time;
            //根据权重随机
            float number = Random.Range(0, actionWeight[0] + actionWeight[1] + actionWeight[2]);

            if (number <= actionWeight[0])
            {
                currentState = MonsterState.STAND;
                thisAnimator.SetTrigger("Stand");
            }
            else if (actionWeight[0] < number && number <= actionWeight[0] + actionWeight[1])
            {
                currentState = MonsterState.CHECK;
                thisAnimator.SetTrigger("Check");
            }
            if (actionWeight[0] + actionWeight[1] < number && number <= actionWeight[0] + actionWeight[1] + actionWeight[2])
            {
                currentState = MonsterState.WALK;
                //随机一个朝向
                targetRotation = Quaternion.Euler(0, Random.Range(1, 5) * 90, 0);
                thisAnimator.SetTrigger("Walk");
            }
        }
    private void SetState(MonsterState state)
    {
        CancelAllTimers(kStateTimerTag);

        m_state = state;
        m_navMeshAgent.Stop();
    }
 void Start()
 {
     //_initialRandomTime = Random.Range(0f, 3f);
     //_randomSpeed = Random.Range(1f, 1.7f);
     initialPosition = transform.position;
     monsterState    = MonsterState.idle;
 }
Esempio n. 8
0
    //2D 가없 을경 우3D
    void OnTriggerEnter2D(Collider2D other)
    {
        interval = 0.0f;
        print("OnTriggerEnter2DMonster" + other.name);
        //총알 을맞았 을경 우
        if(state == MonsterState.MonsterState_IDLE){
            state = MonsterState.MonsterState_DAMAGE;
            animator.SetInteger("State", (int)state);

        }
        hp--;
        /*else if(state == MonsterState.MonsterState_DAMAGE && hp == 0)
        {
            state = MonsterState.MonsterState_DIE;
            animator.SetInteger("State", (int)state);
        }*/
        if(hp <= 0)
        {
            if(isFireMonster == true){
                foreach(Monster monster in otherMonster)
                {
                    if(monster == null)
                        continue;

                    monster.Die();
                }
            }
            Die ();
        }
    }
Esempio n. 9
0
	public Monster(int attack, int health, float speed, int range, bool contagious) : base(health, speed, range) {
		AttackDamage = attack;
		state = MonsterState.IDLE;
		AttackReady = true;
		alienTargets = new List<GameObject> ();
		isContagious = contagious;
	}
Esempio n. 10
0
    //定期检查怪兽当前状态并更新MonsterState值
    IEnumerator CheckMonsterState()
    {
        while (!isDie)
        {
            //等待0.2秒后再执行后续代码

            yield return(new WaitForSeconds(0.2f));

            //测量怪兽与玩家之间的距离
            float dist = Vector3.Distance(playerTr.position, monsterTr.position);

            if (dist <= attackDist)
            {
                monsterState = MonsterState.attack;
            }
            else if (dist <= traceDist)
            {
                monsterState = MonsterState.trace;                //将怪兽状态设置为追击
            }
            else
            {
                monsterState = MonsterState.idle;
            }
        }
    }
Esempio n. 11
0
    IEnumerator PlayerAction()
    {
        while (true) {

            switch(nowState)
            {
            case MonsterState.Created:
                nowState = MonsterState.Idle;
                break;

            case MonsterState.Idle:
                nowState = MonsterState.Run;
                //animator.SetTrigger("Attack");
                break;

            case MonsterState.Run:
                nowState = MonsterState.Idle;
                //animator.SetTrigger("Idle");
                //waitSecond += 2.0f;
                break;

            case MonsterState.Hit:
                nowState = MonsterState.Run;
                break;

            }
            yield return 0;
        }
    }
Esempio n. 12
0
 //BOSS处于行走状态,根据主角与他的距离,(状态,血量)进行思考
 void WalkCheck()
 {
     diatanceToPlayer  = Vector3.Distance(player.transform.position, this.transform.position);
     diatanceToInitial = Vector3.Distance(initialPosition, this.transform.position);
     if (diatanceToInitial > wanderRadius)
     {
         currentState = MonsterState.RETURN;
     }
     //玩家在警戒半径外 ,状态为移动或者站立
     else if (diatanceToPlayer >= alertRadius)
     {
     }
     //玩家在警戒范围内,自卫范围外,状态变为警戒
     else if (defendRadius < diatanceToPlayer && diatanceToPlayer < alertRadius)
     {
         print("走路进入警戒范围\n");
         currentState = MonsterState.WARN;
     }
     //玩家在自卫范围内,状态变为追击
     else if (diatanceToPlayer < defendRadius && attackRange < diatanceToPlayer)
     {
         print("进入自卫范围\n");
         currentState = MonsterState.RUN;
     }
     //玩家在自卫范围内,状态变为攻击
     else if (attackRange > diatanceToPlayer)
     {
         print("进入攻击范围");
         currentState = MonsterState.ATTACK;
     }
 }
Esempio n. 13
0
 public State(MonoBehaviour mono)
 {
     this.Mono = mono;
     monster   = Mono.GetComponent <MonsterUnit>();
     state     = Mono.GetComponent <MonsterState>();
     agent     = mono.GetComponent <NavMeshAgent>();
 }
    private void Sight()
    {
        m_state = MonsterState.Sight;
        PlayRandomAudioClip(m_data.audio.sight);

        StartChasing();
    }
Esempio n. 15
0
    public void AcquireTargetPlayer()
    {
        float nearestDistance = Mathf.Infinity;

        GameObject[] playerGOs = GameObject.FindGameObjectsWithTag("Player");
        targetGO = null;
        for (int i = 0; i < playerGOs.Length; i++)
        {
            if (playerGOs[i] && agent && playerGOs[i].GetComponent <NetworkPlayerManager>().getHealth() > 0)
            {
                Vector3 direction = playerGOs[i].transform.position - transform.position;
                if (direction.magnitude < 20 && direction.magnitude < nearestDistance)
                {
                    nearestDistance    = direction.magnitude;
                    targetGO           = playerGOs[i];
                    direction.y        = 0;
                    transform.rotation = Quaternion.LookRotation(direction);
                    currentState       = MonsterState.Seek;

                    //within attack target range
                    if (direction.magnitude < 2.5)
                    {
                        currentState = MonsterState.Attack;
                    }
                }
            }
        }
    }
 void Back()
 {
     if (agent.remainingDistance <= deadZone)
     {
         selfState = MonsterState.idle;
     }
 }
Esempio n. 17
0
    /// <summary>
    /// 根據權重隨機待機指令
    /// </summary>
    void RandomAction()
    {
        myRigidbody.velocity = Vector2.zero;
        lastActTime          = Time.time; //更新行動時間

                                          //根據權重 隨機選擇待機,觀察,遊走模式
                float number = Random.Range(0, actionWeight[0] + actionWeight[1] + actionWeight[2]);

        if (number <= actionWeight[0])
        {
            currentState = MonsterState.STAND;
            thisAnimator.SetTrigger("Stand");
        }
        else if (actionWeight[0] < number && number <= actionWeight[0] + actionWeight[1])
        {
            currentState = MonsterState.CHECK;
            thisAnimator.SetTrigger("Check");
        }
        if (actionWeight[0] + actionWeight[1] < number && number <= actionWeight[0] + actionWeight[1] + actionWeight[2])
        {
            currentState = MonsterState.WALK;
            //附近隨機一個座標
            Vector2 targetPosOffset = new Vector2(Random.Range(-wanderRadius, wanderRadius), Random.Range(-wanderRadius, wanderRadius));
            targetPosition = new Vector3(transform.position.x + targetPosOffset.x, transform.position.y + targetPosOffset.y, transform.position.z);
        }
    }
Esempio n. 18
0
    /// <summary>
    /// 游走状态检测,检测敌人距离及游走是否越界
    /// </summary>
    void WanderRadiusCheck()
    {
        diatanceToPlayer  = Vector3.Distance(playerUnit.transform.position, transform.position);
        diatanceToInitial = Vector3.Distance(transform.position, initialPosition);

        if (diatanceToPlayer < attackRange)
        {
            //SceneManager.LoadScene("Battle");
            AnimatorState("Atk");
            //執行戰鬥
        }
        else if (diatanceToPlayer < defendRadius)
        {
            currentState = MonsterState.CHASE;
        }
        else if (diatanceToPlayer < alertRadius)
        {
            currentState = MonsterState.WARN;
        }

        if (diatanceToInitial > wanderRadius)
        {
            //朝向调整为初始方向
            targetRotation = Quaternion.LookRotation(initialPosition - transform.position, Vector3.up);
        }
    }
Esempio n. 19
0
 private void StartDissapearing(MonsterState stateToGoAfter)
 {
     _currentState      = MonsterState.MovingToCenter;
     _dissapearingState = stateToGoAfter;
     _dissapearing      = true;
     _alphaTime         = 0f;
 }
Esempio n. 20
0
    IEnumerator CheckMonsterState()//일정한 간격으로 몬스터의 행동 상태를 체크하고 몬스터스테이트 값 변경
    {
        while (!isDie)
        {
            yield return(new WaitForSeconds(0.2f));

            //몬스터와 플레리어 사이의 거리 측정
            float dist = Vector3.Distance(playerTr.position, monsterTr.position);

            if (dist <= attackDist)
            {//공격거리범위 이내로 들어왔는지 확인
                monsterState = MonsterState.attack;
                yield return(new WaitForSeconds(1.8f));
                //break;
            }
            else if (dist <= traceDist)
            {//추적거리 범위 이내로 들어왔는지 확인
                monsterState = MonsterState.trace;
            }
            else
            {
                monsterState = MonsterState.idle;
            }
        }
    }
Esempio n. 21
0
    /// <summary>
    /// 根据权重随机待机指令
    /// </summary>
    void RandomAction()
    {
        //更新行动时间
        //lastActTime = Time.time;
        //Debug.Log(Time.time);
        //根据权重随机
        float number = Random.Range(0, actionWeight[0] + actionWeight[1] + actionWeight[2]);

        if (number <= actionWeight[0])
        {
            currentState = MonsterState.STAND;
            //Debug.Log("stand");
            //thisAnimator.SetTrigger("Idle");
        }
        else if (actionWeight[0] < number && number <= actionWeight[0] + actionWeight[1])
        {
            currentState = MonsterState.CHECK;
            //Debug.Log("check");
            //thisAnimator.SetTrigger("Idle");
        }
        if (actionWeight[0] + actionWeight[1] < number && number <= actionWeight[0] + actionWeight[1] + actionWeight[2])
        {
            //Debug.Log("walk");
            //随机一个朝向
            targetRotation = Quaternion.Euler(0, Random.Range(1, 9) * 45, 0);
            currentState   = MonsterState.WALK;
            //thisAnimator.SetTrigger("Run");
        }
    }
Esempio n. 22
0
    //Boss处于警戒状态,根据主角与他的距离,(状态,血量)进行思考
    void WarnCheck()
    {
        diatanceToPlayer  = Vector3.Distance(player.transform.position, this.transform.position);
        diatanceToInitial = Vector3.Distance(initialPosition, this.transform.position);
        //玩家在警戒半径外 ,状态为移动或者站立

        if (glb.getMonsterFlag(tags) == 1)
        {
            currentState = MonsterState.RUN;
        }
        else if (diatanceToPlayer >= alertRadius)
        {
            print("Boss Warn To Stand");
            currentState = MonsterState.STAND;
        }
        //玩家在警戒范围内,自卫范围外,但在游走范围外 ,状态变为回出生点
        else if (diatanceToInitial > wanderRadius)
        {
            //currentState = MonsterState.RETURN;
        }
        //玩家在自卫范围内,状态变为追击
        else if (diatanceToPlayer < defendRadius)
        {
            if (glb.getMonsterFlag(tags) == 0)
            {
                glb.changeMonsterFlag(tags, 1);
            }
            print("Boss Warn To Run");
            currentState = MonsterState.RUN;
        }
    }
Esempio n. 23
0
 //BOSS处于站立状态,根据主角与他的距离,(状态,血量)进行思考
 private void StandCheck()
 {
     diatanceToPlayer  = Vector3.Distance(player.transform.position, this.transform.position);
     diatanceToInitial = Vector3.Distance(initialPosition, this.transform.position);
     //玩家在警戒半径外 ,状态为移动或者站立
     if (glb.getMonsterFlag(tags) == 1)
     {
         currentState = MonsterState.RUN;
     }
     else if (diatanceToPlayer >= alertRadius)
     {
     }
     //玩家在警戒范围内,自卫范围外,状态变为警戒
     else if (defendRadius < diatanceToPlayer && diatanceToPlayer < alertRadius)
     {
         print("Boss Stand to Warn");
         currentState = MonsterState.WARN;
     }
     //玩家在自卫范围内,状态变为追击
     else if (diatanceToPlayer < defendRadius)// && attackRange < diatanceToPlayer)
     {
         if (glb.getMonsterFlag(tags) == 0)
         {
             glb.changeMonsterFlag(tags, 1);
         }
         print("Boss Stand to Run");
         currentState = MonsterState.RUN;
     }
     //玩家在自卫范围内,状态变为攻击
     else if (attackRange > diatanceToPlayer)
     {
         //currentState = MonsterState.ATTACK;
     }
 }
Esempio n. 24
0
 void sleepState()
 {
     Debug.Log("Entering Sleep-state.");
     targetPosition = targetPatrol.transform.position;
     currentState   = MonsterState.Sleep;
     _animator.Play(Animator.StringToHash("Troll_Idle"));
 }
    public void TurnOnRagdoll()
    {
        customGravity.bEnabled = false;
        currentState           = MonsterState.Dead;
        if (agent.enabled)
        {
            agent.isStopped = true;
        }

        gameObject.GetComponent <Rigidbody>().isKinematic = false;
        gameObject.GetComponent <Rigidbody>().useGravity  = false;


        gameObject.GetComponent <CapsuleCollider>().enabled = false;
        gameObject.GetComponent <Animator>().enabled        = false;
        gameObject.GetComponent <Animator>().avatar         = null;

        foreach (Collider c in ragdollParts)
        {
            c.enabled = true;
            c.attachedRigidbody.isKinematic = false;
            c.attachedRigidbody.velocity    = Vector3.zero;
            c.attachedRigidbody.AddForce(-transform.forward * 7f, ForceMode.Impulse);
        }
    }
Esempio n. 26
0
 /*
  * Switches monster into walkState.
  */
 void walkState()
 {
     Debug.Log("Entering Walk-state");
     _animator.Play(Animator.StringToHash("Troll_Walk"));
     targetPosition = targetPatrol.transform.position;
     currentState   = MonsterState.Walk;
 }
Esempio n. 27
0
        void ChangeState(MonsterState state)
        {
            if (monsterState == state)
            {
                return;
            }

            OnExitState(state);

            switch (state)
            {
            case MonsterState.Run:
                _Anim.Play("RammingMonster");
                CanDie = false;
                break;

            case MonsterState.Attack:
                _Anim.Play("RammingMonster_Dashing");
                CanDie = false;
                break;

            case MonsterState.Dizzy:
                _Anim.Play("RammingMonster_Dizzy");
                CanDie = true;
                break;
            }

            monsterState = state;
        }
Esempio n. 28
0
    void MonsterDie()//モンスター死亡時の処理過程
    {
        DragonHPBar.SetActive(false);
        FinalBoss.SetActive(true);      //FinalBoss(次のボス)が現れる
        FinalBossHPBar.SetActive(true); //FinalBoss(次のボス)のHPバーが現れる
        FinalBossSyutsugen.SetActive(true);
        Damage.GetComponent <PlayerCtrl>().BGMSource.clip = Damage.GetComponent <PlayerCtrl>().BossBGM;
        Damage.GetComponent <PlayerCtrl>().BGMSource.Play();
        _animator.SetTrigger("IsDie");
        Destroy(FinalBossSyutsugen, 10.0f);           //10秒後ドラゴン出没メッセージを消す
        gameUI.DispScore(1000);                       //経験値付与
        gameUI.GetComponent <GameUI>().HPpotion += 1; //プレイヤーHPポーション獲得
        gameUI.GetComponent <GameUI>().MPpotion += 1; //プレイヤーMPポーション獲得

        StopAllCoroutines();                          //すべてのコルーチン停止
        isDie        = true;
        monsterState = MonsterState.die;
        nvAgent.Stop();
        gameObject.GetComponentInChildren <BoxCollider>().enabled = false;
        gameObject.GetComponent <NavMeshAgent>().enabled          = false;
        gameUI.DispScore(0);
        Speed    = 0.0f;
        rotSpeed = 0.0f;
        lookat   = 0;
        FireObject.SetActive(false);
        StartCoroutine(this.PushObjectPool());
    }
Esempio n. 29
0
    IEnumerator CheckMonsterState()
    {
        while (!isDie)
        {
            yield return(new WaitForSeconds(0.2f));

            if (isUsing)
            {
                if (targetPtr == null)
                {
                    float dist = Vector3.Distance(new Vector3(1, 0.04f, 310), tr.position);
                }
                else
                {
                    float dist = Vector3.Distance(targetPtr.position, tr.position);
                    if (monsterState != MonsterState.hit)
                    {
                        if (dist <= attackDist)
                        {
                            monsterState = MonsterState.attack;
                        }

                        else if (dist <= traceDist)
                        {
                            monsterState = MonsterState.trace;
                        }
                        else
                        {
                            monsterState = MonsterState.idle;
                        }
                    }
                }
            }
        }
    }
Esempio n. 30
0
    IEnumerator CheckMonsterState()
    {
        while (!isDie)
        {
            yield return(new WaitForSeconds(0.2f));

            float dist = Vector3.Distance(ptr.position, tr.position);
            //Debug.Log (dist);
            if (monsterState != MonsterState.hit)
            {
                if (dist <= attackDist)
                {
                    nvAgent.Stop();
                    monsterState = MonsterState.attack;
                }
                else if (dist <= traceDist && dist > attackDist)
                {
                    monsterState = MonsterState.trace;
                }
                else if (dist > traceDist)
                {
                    monsterState = MonsterState.idle;
                }
            }
        }
    }
Esempio n. 31
0
    //BOSS处于追击状态,根据主角与他的距离,(状态,血量)进行思考
    void RunCheck()
    {
        diatanceToPlayer  = Vector3.Distance(player.transform.position, this.transform.position);
        diatanceToInitial = Vector3.Distance(initialPosition, this.transform.position);
        //玩家在警戒半径外 ,状态为移动或者站立

        if (glb.getMonsterFlag(tags) == 0)
        {
            currentState = MonsterState.RETURN;
        }
        else if (diatanceToPlayer >= alertRadius)
        {
        }
        //玩家在追击范围外 ,状态变为回出生点
        else if (diatanceToInitial > chaseRadius)
        {
            if (glb.getMonsterFlag(tags) == 1)
            {
                glb.changeMonsterFlag(tags, 0);
            }
            print("Boss Run to Return ");
            currentState = MonsterState.RETURN;
        }
        //玩家在攻击范围内,状态变为攻击
        else if (diatanceToPlayer < (attackRange - 1f))
        {
            lastActTime = Time.time;
            print("Boss Run to Attach ");
            currentState = MonsterState.ATTACK;
        }
    }
Esempio n. 32
0
    void MonsterDie()
    {
        //사망하면 태그를 Untagged로 변경
        gameObject.tag = "Untagged";

        //모든 코루틴 정지
        StopAllCoroutines();

        isDie        = true;
        monsterState = MonsterState.die;
        nvAgent.Stop();
        animator.SetTrigger("IsDie");

        //몬스터에 추가된 collider를 비활성ㅇ화
        gameObject.GetComponentInChildren <CapsuleCollider>().enabled = false;

        foreach (Collider coll in gameObject.GetComponentsInChildren <SphereCollider>())
        {
            coll.enabled = false;
        }

        gameUI.DispScore(50);

        //몬스터 오브젝트 풀로 환원시키는 코루틴 함수 호출
        StartCoroutine(this.PushObjectPool());
    }
Esempio n. 33
0
    private void StartAttack()
    {
        if (_gameManager.GameFinished)
        {
            ChangeState(MonsterState.None);
        }
        else
        {
            _animator.Play("BossAttack");

            var newAttack = MonsterState.None;

            if (_firstAttacks.Count > 0)
            {
                newAttack = _firstAttacks[0];
                _firstAttacks.RemoveAt(0);
            }
            else
            {
                do
                {
                    newAttack = (MonsterState)Random.Range((int)MonsterState.Lunging, (int)MonsterState.TotalStates);
                }while(newAttack == _lastAttack);
            }

            _lastAttack = newAttack;
            ChangeState(newAttack);
        }
    }
Esempio n. 34
0
 public void CheckPlayerPos()
 {
     state = MonsterState.CHECK;
     pathFinder.SetDestination(Floor.monsterFloor.mapManager, playerTransform.position, chaseSpeed, 90f, delegate ()
     {
         state = MonsterState.IDLE;
     });
 }
Esempio n. 35
0
 public override void CollisionCheck(Sprite a)
 {
     if (stan==State.alive&&a.typ == Type.player&&monsterowy==MonsterState.move&&Obliczarka.KolizjaDlaOkregow(a,this))
     {
         monsterowy = MonsterState.attack;
         timeOfAttack = 1;
         a.PrzyjmijUderzenie(obrazenia);
     }
 }
Esempio n. 36
0
    void Awake()
    {
        //Component 를얻어온 다.
        // <가져 올컴포넌 트>
        animator = this.GetComponent<Animator>();
        state = MonsterState.MonsterState_IDLE;
        animator.SetInteger("State", (int)state);

        this.rigidbody2D.velocity = new Vector2(0, -2.0f);
    }
Esempio n. 37
0
    void Idle()
    {
        idleTimer += Time.deltaTime;

        if (idleTimer > patrolWaitSeconds)
        {
            idleTimer = 0f;
            state = MonsterState.PATROL;
        }
    }
Esempio n. 38
0
 public Monster()
 {
     _isPassable = false;
     _type = ObjectType.O_MONSTER;
     _monsterBehaviur = MonsterState.MS_IDLE;
     _pathAvaible = false;
     _route = new List<Point>();
     _movement = new List<Point>();
     _seen = false;
 }
Esempio n. 39
0
 public Monster(int[] stats, int[] resists, MonsterFight mf, Classess monClass, int baseM, int basePh, string desc, char vis, ConsoleColor color)
 {
     _isPassable = false;
     _type = ObjectType.O_MONSTER;
     _monsterBehaviur = MonsterState.MS_IDLE;
     _pathAvaible = false;
     _route = new List<Point>();
     _movement = new List<Point>();
     _seen = false;
     _description = desc;
     _visual = vis;
     _color = color;
     _class = monClass;
     _primaryStats = new Dictionary<PrimaryStats, Stat>();
     _resists = new Dictionary<Resists, Stat>();
     _BaseResists = new Dictionary<ResistGroup, Stat>();
     _monsterWeapons = mf.ListOfWeapons;
     _monsterArmor = mf.monsterArmor;
     _weaponProficiencies = new int[mf.ListOfWeapons.GetLength(0)];
     _states = new bool[(int)PlayerStates.MAX_SIZE];
     changeState(PlayerStates.NORMAL);
     for (PrimaryStats i = PrimaryStats.VITALITY; i < PrimaryStats.MAX_SIZE; i++)
     {
         _primaryStats.Add(i, new Stat(stats[(int)i]));
     }
     for (Resists i = Resists.RESIST_1; i < Resists.MAX_SIZE; i++)
     {
         _resists.Add(i, new Stat(resists[(int)i]));
     }
     _BaseResists.Add(ResistGroup.MENTAL, new Stat(baseM));
     _BaseResists.Add(ResistGroup.PHYSICAL, new Stat(basePh));
     Level = 0;
     _Stamina = new Stat(_primaryStats[PrimaryStats.VITALITY].currentValue / 10 + _primaryStats[PrimaryStats.STRENGTH].currentValue / 10);
     //recalculate dex and spd based on armor limitation
     _primaryStats[PrimaryStats.DEXTERITY].actualValue /= _monsterArmor.Limitation[0];
     _primaryStats[PrimaryStats.SPEED].actualValue /= _monsterArmor.Limitation[1];
     //calculate defence without weapon
     _defence = new Stat(_monsterArmor.Defence + Convert.ToInt16(Math.Round((_primaryStats[PrimaryStats.DEXTERITY].actualValue / 10.0f))));
     _protection = new int[3];
     _protection[0] = _monsterArmor.Protection[0];
     _protection[1] = _monsterArmor.Protection[1];
     _protection[2] = _monsterArmor.Protection[2];
     //genereate weapon proficiency for all weapons
     for (int i = 0; i < _monsterWeapons.GetLength(0); i++)
     {
         int bonus = _monsterWeapons[i].ProfBonus;
         int prof = bonus + Data.PlayerClass.ClassProficiencyTable[_class][1] + Dice.Roll("d50");
         _weaponProficiencies[i] = prof;
     }
     _steps = 0;
     _exp = MonsterGenerator.CalcualteMonsterExp(this);
     //calcualte magic potential for future casters
     _MagicPotential = new Stat(0);
     CalculateMagicPotential();
 }
Esempio n. 40
0
    public override void GetDemage(int demageValue)
    {
        demageManager.GetComponent<DemageManager> ().CreateDemageText (demageValue,this.transform);
        Hit ();

        helth -= demageValue;

        if (helth < 1) {
            nowState = MonsterState.Dead;
            animator.SetBool("Dead",true);

            StartCoroutine(Dead());
        }
    }
    /*
     * 일정한 간격으로 몬스터의 할동 상태를 체크하고 monsterState값 변경.
     */
    IEnumerator CheckMonsterState()
    {
        while (!isDie)
        {
            yield return new WaitForSeconds(0.2f);
            //몬스터의 플레이어 사이의 거리 측정.
            float dist = Vector3.Distance(playerTr.position, bossTr.position);

            if (dist <= attackDist) //공격 범위 이내로 들어왔는지 확인.
                monsterState = MonsterState.attack;
            else if (dist <= traceDist) //추적거리 범위 이내로 들어왔는지 확인.
                monsterState = MonsterState.trace;
            else //몬스터의 상태를 idle 모드로 설정.
                monsterState = MonsterState.idle;
        }
    }
Esempio n. 42
0
    IEnumerator CheckMonsterState()
    {
        while (!isDie) {
            yield return new WaitForSeconds (0.2f);
            float dist = Vector3.Distance (playerTr.position, monsterTr.position);

            if (dist <= attackDist) {
                monsterState = MonsterState.attack;
            } else if (dist <= traceDist) {
                monsterState = MonsterState.trace;
            }else{
                monsterState = MonsterState.idle;
            }

        }
    }
Esempio n. 43
0
 public Monster(int x, int y, char visual, ConsoleColor color)
 {
     _posX = x;
     _posY = y;
     _oldX = x;
     _oldY = y;
     _visual = visual;
     _isPassable = false;
     _color = color;
     _description = "an orc";
     _type = ObjectType.O_MONSTER;
     _monsterBehaviur = MonsterState.MS_IDLE;
     _pathAvaible = false;
     _route = new List<Point>();
     _movement = new List<Point>();
     _seen = false;
 }
    public void SetBehaviourState( MonsterState state )
    {
        switch(state)
        {
        case MonsterState.Idling:
            m_characterAnimation.SetAnimationState("Idle");
            break;
        case MonsterState.Creeping:
            m_characterAnimation.SetAnimationState("Idle");
            break;
        case MonsterState.Crawling:
            m_characterAnimation.SetAnimationState("Crawl");
            break;
        }

        m_state = state;
    }
    public CharacterState GetPlayerStateFromType( PlayerType type )
    {
        CharacterState state = null;
        switch (type) {
            case PlayerType.PLAYER:
                state = new NormalState( gameObject );
                break;
            case PlayerType.MONSTER:
                state = new MonsterState( gameObject );
                break;
            case PlayerType.AI_MONSTER:
                state = new AIMonsterState( gameObject );
                break;
            case PlayerType.AI_PLAYER:
                state = new AIState( gameObject );
                break;
        }

        return state;
    }
Esempio n. 46
0
	void SetState(MonsterState _state)
	{
		if (animator == null) return;
		switch (_state)
		{
			case MonsterState.Walk:
				break;
				
			case MonsterState.Idle:
				break;
				
			case MonsterState.Attack:
				break;
				
			case MonsterState.Hit:
				break;
				
			case MonsterState.Dead:
				break;
		}
	}
Esempio n. 47
0
    /*
     * 一定の間隔でモンスターのステートをチェックしてmonsterState値を変更
     */
    IEnumerator CheckMonsterState()
    {
        while (!isDie) {
            yield return new WaitForSeconds(0.2f);

            // モンスターとプレイヤーとの間の距離を測定
            float dist = Vector3.Distance(playerTr.position, monsterTr.position);
            if(dist <= attackDist)	// 攻撃範囲距離内に入っているかを確認
            {
                monsterState = MonsterState.attack;
            }
            else if (dist <= traceDist)	// 追跡範囲距離内に入っているかを確認
            {
                monsterState = MonsterState.trace;	// モンスターのステートを追跡モードに設定
            }
            else
            {
                monsterState = MonsterState.idle;	// モンスターのステートをidleモードに設定
            }
        }
    }
Esempio n. 48
0
	public void Attack(Alien a)
    {   
		if (AttackReady && GameObject.tag != "Dead") {
			state = MonsterState.ATTACKING;
			a.TakeDamage(AttackDamage, this);
            if (isContagious && !a.Infected)
            {
                a.Infected = true;
                a.GameObject.transform.Find("Infection").GetComponent<ParticleSystem>().Play();
            }

            GameObject.GetComponent<Animation>().CrossFade("Attack", 0.1f, PlayMode.StopAll);

            if((GameObject.transform.position - a.GameObject.transform.position).sqrMagnitude > 2f)
                MoveTo(a.GameObject.transform.position);

			// Start cooldown of attack
			AttackReady = false;
			GameObject.GetComponent<MonsterHelper>().StartCoolDown(COOLDOWN, this);
		}
    }
Esempio n. 49
0
    IEnumerator BoarAction()
    {
        //루프
        while (true) {

            if(passedTime > waitSecond)
            {
                waitSecond = (rdm.Next(100)+200)/100;  //결과 2.6  3.5 이런것 나온다.
                passedTime = 0;

                //beforeState = nowState;

                switch(nowState)
                {
                case MonsterState.Created:
                    nowState = MonsterState.Idle;
                    break;

                case MonsterState.Idle:
                    nowState = MonsterState.Run;
                    animator.SetTrigger("Attack");
                    break;

                case MonsterState.Run:
                    nowState = MonsterState.Idle;
                    animator.SetTrigger("Idle");
                    waitSecond += 2.0f;
                    break;

                case MonsterState.Hit:
                    nowState = MonsterState.Run;
                    break;
                }
            }

            //0.1초 간격으로 재호출
            yield return new WaitForSeconds(0.1f);
        }
    }
    /*
     * 일정한 간격으로 몬스터의 할동 상태를 체크하고 monsterState값 변경.
     */
    IEnumerator CheckMonsterState()
    {
        while (!isDie)
            {

                //    Debug.Log("CheckMonsterState");
                yield return new WaitForSeconds(0.2f);
                //몬스터의 플레이어 사이의 거리 측정.
                float dist = Vector3.Distance(playerTr.position, monsterTr.position);

                //if (Network.peerType == NetworkPeerType.Server)
                //{
                if (dist <= attackDist) //공격 범위 이내로 들어왔는지 확인.
                    monsterState = MonsterState.attack;
                else if (dist <= traceDist) //추적거리 범위 이내로 들어왔는지 확인.
                    monsterState = MonsterState.trace;
                else //몬스터의 상태를 idle 모드로 설정.
                    monsterState = MonsterState.idle;

                //}
            }
    }
Esempio n. 51
0
    void Patrol()
    {
        if (Floor.monsterFloor != null && !pathFinder.isMoving)
        {
            if(Floor.monsterFloor != Floor.playerFloor)
            {
                Invoke("MoveToPlayerFloor", Random.Range(5f, 30f));
                state = MonsterState.NONE;
                return;
            }

            Transform movePos = Floor.monsterFloor.GetRandomMonsterMoveTransform();
            while (movePos.position == cachedTransform.position)
            {
                movePos = Floor.monsterFloor.GetRandomMonsterMoveTransform();
            }

            pathFinder.SetDestination(Floor.monsterFloor.mapManager, movePos.position, walkSpeed, 90f, delegate()
            {
                state = MonsterState.IDLE;
            });
        }
    }
Esempio n. 52
0
    void MonsterDie()
    {
        StopAllCoroutines ();

        isDie = true;
        monsterState = MonsterState.die;
        nvAgent.Stop ();
        _animator.SetBool ("IsDie", true);

        gameObject.GetComponentInChildren<CapsuleCollider> ().enabled = false;

        foreach (Collider coll in gameObject.GetComponentsInChildren<SphereCollider>()) {
            coll.enabled = false;
        }
    }
Esempio n. 53
0
 //fireMonster 일경 우Monster 전 체삭
 public void Die()
 {
     state = MonsterState.MonsterState_DIE;
     animator.SetInteger("State", (int)state);
     //CreateGold();
 }
Esempio n. 54
0
    void Update()
    {
        if(state == MonsterState.MonsterState_DAMAGE)
        {
            interval += Time.deltaTime;
            if(interval > intervalMax){
                interval = 0.0f;
                state = MonsterState.MonsterState_IDLE;
                animator.SetInteger("State", (int)state);
            }
        }

        /*
        //mouse left click
        if(Input.GetMouseButtonDown(0) == true){
            // C#에서 는포인트 가.으 로표현 됨
            animator.SetInteger("State", 0);
        }
        else if(Input.GetMouseButtonDown(1) == true){

            animator.SetInteger("State", 1);

        }*/
    }
Esempio n. 55
0
 void MoveToPlayerFloor()
 {
     cachedTransform.position = Floor.playerFloor.GetRandomMonsterMoveTransform().position;
     state = MonsterState.IDLE;
 }
Esempio n. 56
0
 public void SetDelayBeforeHatching(int value)
 {
     this.MonsterState = MonsterState.Egg;
     this._hatchingTimer = new GameTimer(this.World.Game, value*AnimationPlayer.GameClockResolution, EggIsHatching, false);
 }
Esempio n. 57
0
 private void EggHasHatched(object sender, SoundEffectFinishedEventArgs args)
 {
     this.MonsterState = MonsterState.Normal;
 }
Esempio n. 58
0
 private void EggIsHatching(object sender, EventArgs args)
 {
     this.MonsterState = MonsterState.Hatching;
     this.World.Game.SoundPlayer.Play(GameSound.EggHatches, EggHasHatched);
 }
Esempio n. 59
0
    // Update is called once per frame
    void Update()
    {
        if (canControl == false)
            return;

        h = Input.GetAxis ("Horizontal");

        if (h != 0) {
            preStrate = nowState;
            nowState = MonsterState.Run;

            if(h < 0)
                transform.rotation = Quaternion.Euler(new Vector3(0,180,0));

            if(h > 0)
                transform.rotation = Quaternion.Euler(new Vector3(0,0,0));

        } else {
            preStrate = nowState;
            nowState = MonsterState.Idle;
        }

        if (preStrate != nowState) {
            StateChangeFlag = true;
        }

        if (StateChangeFlag == true) {
            switch(nowState)
            {
            case MonsterState.Run:
                GetComponent<Animator>().SetTrigger("Run");
                break;
            case MonsterState.Idle:
                GetComponent<Animator>().SetTrigger("Walk");
                break;
            }
            StateChangeFlag = false;
        }

        Vector3 moveDir = (Vector3.forward * v) + (Vector3.right * h);

        tr.Translate(moveDir * moveSpeed * Time.deltaTime, Space.World);
        //tr.Rotate(Vector3.up * Time.deltaTime * rotSpeed * Input.GetAxis("Mouse X"));

        if (Input.GetKeyDown (KeyCode.Space)) {
            Vector3 Temp = this.GetComponent <Rigidbody2D>().velocity;
            Temp.y = 10.0f;
            this.GetComponent <Rigidbody2D>().velocity = Temp;
        }

        if (Input.GetMouseButtonDown(0))
        {

            FireBall();
            //GameObject dialogManager = GameObject.Find("DialogManager");
            //dialogManager.SendMessage("OnDialog",0,SendMessageOptions.DontRequireReceiver);

        }
        if (Input.GetMouseButtonDown(1))
        {
            IceRain();
            //GameObject dialogManager = GameObject.Find("DialogManager");
            //dialogManager.SendMessage("OnDialog",1,SendMessageOptions.DontRequireReceiver);

        }
    }
Esempio n. 60
0
    // Use this for initialization
    void Start()
    {
        tr 		= GetComponent<Transform>();
        rgdbd = GetComponent<Rigidbody2D> ();

        nowState = MonsterState.Idle;
        preStrate = MonsterState.Idle;

        StateChangeFlag = false;
        //fireBall = (GameObject)Resources.Load("FireBall", typeof(GameObject));
    }