Пример #1
0
        public void EnvironmentAffected()
        {
            if (myState != CreatureState.JUST_ADDED_OR_MOVED)
            throw new Exception("Невыполнение средой условий последовательности вызова {E1E39E8B-F0B6-4215-B7D3-1BBA8A1661CA}");

              myState = CreatureState.ENVIRONMENT_AFFECTED;
              myCNS.NotifyEnvironmentAffected();
              myState = CreatureState.CREATURE_REACTED;
        }
Пример #2
0
    public virtual void Start()
    {
        PlayerCamera.OnCameraEventStart += PauseAI;
        PlayerCamera.OnCameraEventEnd   += ResumeAI;

        OriginalPrefab = this.gameObject;
        OriginalHealth = Health;
        if (RotationObject == null)
        {
            RotationObject = this.transform;
        }
        if (anim == null)
        {
            anim = GetComponent <Animator>();
        }

        thisRigidbody    = GetComponent <Rigidbody>();
        thisNavMeshAgent = GetComponent <NavMeshAgent>();
        //print(thisNavMeshAgent);
        if (thisNavMeshAgent != null)
        {
            startPosition = thisNavMeshAgent.nextPosition;
            thisNavMeshAgent.ResetPath();
        }

        currentState = CreatureState.none;

        StateSwitchInstance = StateSwitch();
        StartCoroutine(StateSwitchInstance);

        ObservantInstance = Awareness();
        StartCoroutine(ObservantInstance);

        currentVisionRange = AgroRange;
        if (Debugging.RaycastVisionRange)
        {
            if (thisNavMeshAgent != null)
            {
                Utility.RayVisionRange(30, thisNavMeshAgent.nextPosition, 0.5f, 10f, AgroRange, Color.gray);
                Utility.RayVisionRange(30, thisNavMeshAgent.nextPosition, 0.5f, 10f, fullVisionRange, Color.black);
            }
            else
            {
                Utility.RayVisionRange(30, transform.position, 0.5f, 10f, AgroRange, Color.cyan);
                Utility.RayVisionRange(30, transform.position, 0.5f, 10f, fullVisionRange, Color.black);
            }
        }

        if (GetComponentInChildren <Weapon>() != null)
        {
            WeaponCollider = GetComponentInChildren <Weapon>().gameObject.GetComponent <Collider>();
        }
        GameManager.DayNightCall += SetDayTime;
    }
Пример #3
0
    //1 Frame running
    private void Charge()
    {
        moleState      = CreatureState.charging;
        goIdleCooldown = true;

        if (goCharge)
        {
            CheckDirection();
            StartCoroutine(ChargeCoroutine());
        }
    }
Пример #4
0
 //-------------------------------------------------------------------------------------------------------
 //public override bool HitTest(Ray ray, out RaycastHit rayHit)
 //{
 //    if (m_EntityView != null)
 //    {
 //        return m_EntityView.HitTest(ray,out rayHit);
 //    }
 //    rayHit = new RaycastHit();
 //    return false;
 //}
 //-------------------------------------------------------------------------------------------------------
 public override void ChangeState(CreatureState state, object param = null)
 {
     if (m_FMS != null)
     {
         //if (EntitySystem.m_ClientGlobal.IsMainPlayer(this as IEntity))
         //{
         //    UnityEngine.Debug.Log("ChangeState ..." + state);
         //}
         m_FMS.ChangeState((int)state, param);
     }
 }
Пример #5
0
 /// <summary>
 /// Creature seeks out player and attacks when it gets close.
 /// </summary>
 void Attack()
 {
     state = CreatureState.SeekEnemy;
     navMesh.SetDestination(player.transform.position);
     if (Vector3.Distance(transform.position, player.transform.position) <= stopDistance)
     {
         navMesh.SetDestination(transform.position);
         state = CreatureState.Attacking;
         FaceTarget(player.transform);
     }
 }
Пример #6
0
 /// <summary>
 /// Creature seeks out player and waits for food.
 /// </summary>
 void SeekFood()
 {
     state = CreatureState.SeekFood;
     navMesh.SetDestination(player.transform.position);
     if (Vector3.Distance(transform.position, player.transform.position) <= stopDistance)
     {
         navMesh.SetDestination(transform.position);
         state = CreatureState.Waiting;
         FaceTarget(player.transform);
     }
 }
Пример #7
0
    public void Update(CreatureState creatureState, UnityEngine.Transform parentTransform)
    {
        var mainCamera = UnityEngine.Camera.main;

        _fov    = mainCamera.fieldOfView;                                                 //  60.0f; //todo
        _aspect = ((float)UnityEngine.Screen.width) / ((float)UnityEngine.Screen.height); //16.0f / 9.0f;

        _faceGameObject.transform.parent = parentTransform;

        UpdateFace(creatureState, mainCamera, creatureState.creatureStateBody.height);
    }
Пример #8
0
 public void ChangeState(CreatureState newCreatureState)
 {
     if (creatureState != newCreatureState && !dead)
     {
         creatureState = newCreatureState;
         if (animator == null)
         {
             animator = GetComponent <Animator>();
         }
         animator.SetTrigger(newCreatureState.ToString());
     }
 }
Пример #9
0
 protected override void ChangeState(CreatureState state)
 {
     if (state == CreatureState.Shocked)
     {
         Horn();
     }
     else if (state == CreatureState.Fleeing)
     {
         Howl();
     }
     base.ChangeState(state);
 }
Пример #10
0
 protected virtual void Initialize()
 {
     CurrentState   = CreatureState.Wander;
     targetPosition = transform.position;
     curSpeed       = 4.0f; curRotSpeed = 5.0f;
     SetTarget(transform.FindChild("Target").gameObject);
     SetTargetParent(null);
     SetTargetFood(target);
     health        = 5;
     movementRange = 100;
     GetNewWanderTarget();
 }
Пример #11
0
    protected override void ChangeState(CreatureState state)
    {
        if (state == CreatureState.Shocked && currState != CreatureState.Shocked)
        {
            if (TimesTeleported++ < 2)
            {
                transform.position = new Vector3(transform.position.x, transform.position.y, transform.position.z - 6.5f);
            }
        }

        base.ChangeState(state);
    }
Пример #12
0
    public virtual void OnDamaged(float damage)
    {
        if (_currentHp > 0)
        {
            _currentHp -= damage;
        }

        else
        {
            State = CreatureState.Dead;
        }
    }
Пример #13
0
 protected override void ChangeState(CreatureState state)
 {
     if (currState == CreatureState.Default)
     {
         animator.SetBool("walk", false);
     }
     if (state == CreatureState.Fleeing)
     {
         speed *= 1.5f;
     }
     base.ChangeState(state);
 }
Пример #14
0
        public void Advantage()
        {
            if (myState != CreatureState.CREATURE_REACTED)
            throw new Exception("Невыполнение средой условий последовательности вызова {0BEE6BB2-AF26-4FE5-B2A6-65B84227B77E}");

              s0lu.Advantage();
              s1ru.Advantage();
              s2rd.Advantage();
              s3ld.Advantage();

              myState = CreatureState.JUST_ADDED_OR_MOVED;
        }
Пример #15
0
    private void DealEndTouch(CreatureState creatureState, TouchData touchData, CreatureStateHud.TUIElement uiElement)
    {
        //do we have jump input
        if ((crouchTime < touchData.duration) || (CreatureStateHud.TUIElement.Movement != uiElement))
        {
            return;
        }
        var normalisedRatio = ((touchData.duration / crouchTime) * 2.0f) - 1.0f; //normalise -1 ... 1
        var temp            = normalisedRatio * normalisedRatio;

        creatureState.creatureStateInput.jump = 1.0f - temp;
    }
Пример #16
0
    /// <summary>
    /// Assignments and code called on start.
    /// </summary>
    public virtual void OnStart()
    {
        stats          = GetComponent <Stats>();
        anim           = GetComponent <Animator>();
        animController = GetComponent <AIAnimationController>();
        audioSource    = GetComponent <AudioSource>();

        state      = CreatureState.Idle;
        allegiance = CreatureAllegiance.Neutral;

        stats.currentMoveSpeed = stats.defaultMoveSpeed;
    }
Пример #17
0
 public Creature()
 {
     m_SceneId      = 0;
     m_MapId        = 0;
     m_Cid          = 0;
     m_CreatureType = CreatureTypeEnum.CREATURE_NONE;
     m_CurState     = CreatureState.State_Init;
     m_SeeLst       = new List <uint>();
     m_BeenSeeLst   = new List <uint>();
     m_Pos          = new Vector3();
     m_Dir          = new Vector3();
     m_ViewLayer    = (uint)ViewLayerType.ENUM_NINE_GRID_LITTLE; //1级9各宫
 }
Пример #18
0
    public void Draw(CreatureState creatureState)
    {
        if ((null == creatureState) || (null == creatureState.creatureStateHud))
        {
            return;
        }

        DrawElements(creatureState);
        DrawTouch(creatureState);


        return;
    }
Пример #19
0
    // Анімований рух
    void AnimateMoving()
    {
        moveTime = Mathf.Min(1, moveTime + Time.deltaTime * speed);
        float height = (1 - 4 * (moveTime - .5f) * (moveTime - .5f)) * moveArcHeight;

        this.position = Vector3.Lerp(moveStartPosition, moveTargetPosition, moveTime) + Vector3.up * height;

        if (moveTime >= 1)
        {
            moveTime   = 0;
            this.state = CreatureState.Standing;
        }
    }
Пример #20
0
    private void DrawElements(CreatureState creatureState)
    {
        UnityEngine.GUI.color = UnityEngine.Color.white;
        //foreach(CreatureStateHud.UIElementData uiElementData in creatureState.creatureStateHud.uiElementDataArray)
        for (int index = 0; index < creatureState.creatureStateHud.uiElementDataArray.Count; ++index)
        {
            var uiElementData = creatureState.creatureStateHud.uiElementDataArray[index];
            switch (uiElementData.uiElement)
            {
            default:
                continue;

            case CreatureStateHud.TUIElement.Weapon:
            case CreatureStateHud.TUIElement.Movement:
            case CreatureStateHud.TUIElement.View:
            {
                var rect = UIPositionToRect(uiElementData.position);
                UnityEngine.GUI.Box(rect, UnityEngine.GUIContent.none, _circleStyle);
            }
            break;

            case CreatureStateHud.TUIElement.Pickup:
            {
                var rect = UIPositionToRect(uiElementData.position);
                UnityEngine.GUI.Button(rect, UnityEngine.GUIContent.none, _circleStyle);
#if false
                if (UnityEngine.GUI.Button(rect, UnityEngine.GUIContent.none, _circleStyle))
                {
                    if ((uiElementData.gameObject) && (creatureState.weaponArray.Count < 8))
                    {
                        creatureState.weaponArray.Add(new CreatureState.WeaponData()
                            {
                                weapon = CreatureState.TWeapon.TSlingPan
                            });

                        UnityEngine.GameObject.Destroy(uiElementData.gameObject);
                        //uiElementData.gameObject = null;
                        creatureState.creatureStateHud.uiElementDataArray[index] = new CreatureStateHud.UIElementData()
                        {
                            position  = uiElementData.position,
                            uiElement = uiElementData.uiElement
                        };
                    }
                }
#endif
            }
            break;
            }
        }
    }
Пример #21
0
    protected override void MoveToNextPos()
    {
        Vector3Int destPos = _destCellPos;

        if (_target != null)
        {
            destPos = _target.GetComponent <CreatureController>().CellPos;

            Vector3Int dir = destPos - CellPos;
            if (dir.magnitude <= _skillRange && (dir.x == 0 || dir.y == 0))
            {
                Dir   = GetDirFromVec(dir);
                State = CreatureState.Skill;

                if (_rangedSkill)
                {
                    _coSkill = StartCoroutine("CoStartShootArrow");
                }
                else
                {
                    _coSkill = StartCoroutine("CoStartPunch");
                }

                return;
            }
        }

        List <Vector3Int> path = Managers.Map.FindPath(CellPos, destPos, ignoreDestCollision: true);

        if (path.Count < 2 || (_target != null && path.Count > 20))
        {
            _target = null;
            State   = CreatureState.Idle;
            return;
        }

        Vector3Int nextPos     = path[1];
        Vector3Int moveCellDir = nextPos - CellPos;

        Dir = GetDirFromVec(moveCellDir);

        if (Managers.Map.CanGo(nextPos) && Managers.Object.Find(nextPos) == null)
        {
            CellPos = nextPos;
        }
        else
        {
            State = CreatureState.Idle;
        }
    }
Пример #22
0
    IEnumerator CoStartShootArrow()
    {
        GameObject      go = Managers.Resource.Instantiate("Creature/Arrow");
        ArrowController ac = go.GetComponent <ArrowController>();

        ac.Dir     = _lastDir;
        ac.CellPos = CellPos;

        // 대기 시간
        yield return(new WaitForSeconds(0.3f));

        State    = CreatureState.Moving;
        _coSkill = null;
    }
Пример #23
0
    protected override void ChangeState(CreatureState state)
    {
        if (state == CreatureState.Shocked)
        {
            Howl();
        }
        else if (state == CreatureState.Fleeing)
        {
            FleeSound();
            speed *= 1.6f;
        }

        base.ChangeState(state);
    }
Пример #24
0
        public void AddStateEntry(Guid id, CreatureState state)
        {
            if (!this.fActive)
            {
                return;
            }
            StateLogEntry stateLogEntry = new StateLogEntry()
            {
                CombatantID = id,
                State       = state
            };

            this.fEntries.Add(stateLogEntry);
        }
Пример #25
0
 public void TalkMode(bool condition)
 {
     if (condition)
     {
         state = CreatureState.talking;
     }
     else
     {
         if (state == CreatureState.talking)
         {
             state = CreatureState.patrolling;
         }
     }
 }
Пример #26
0
 public Bug()
 {
     InitializeComponent();
       s0lu = new s0("lu");
       s1ru = new s0("ru");
       s2rd = new s1("rd");
       s3ld = new s2("ld");
       s2rd.SetTwin(s3ld.mySection);
       s3ld.SetTwin(s2rd.mySection);
       s4S0 = new sS0("ad");
       s5S1 = new sS1("G");
       myState = CreatureState.JUST_ADDED_OR_MOVED;
       myCNS = new CNS(this);
 }
Пример #27
0
    IEnumerator Stunned()
    {
        if (StunParticles != null)
        {
            GameObject StunP = (Instantiate(StunParticles, transform.position + (Vector3.up * 1.4f), Quaternion.identity)) as GameObject;
            Destroy(StunP, StunDuration);
        }
        NavMeshAgentMovement(false);
        yield return(new WaitForSeconds(StunDuration));

        NavMeshAgentMovement(true);

        state = ReturnState;
    }
Пример #28
0
    // Start is called before the first frame update
    void Start()
    {
        navMesh     = GetComponent <NavMeshAgent>();
        anim        = GetComponent <Animator>();
        rb          = GetComponent <Rigidbody>();
        audioSource = GetComponent <AudioSource>();

        state         = CreatureState.Idle;
        navMesh.speed = speed;
        state         = CreatureState.Idle;
        allegiance    = CreatureAllegiance.Neutral;

        player = FindObjectOfType <PlayerController>();
        winConditionManager = FindObjectOfType <WinConditionManager2>();
    }
Пример #29
0
        public void HandleInput(InputHelper inputHelper, GameTime gameTime)
        {
            CreatureState prevState = CreatureState;

            _playerMovingForce = new Vector2(0, 0);
            CreatureState      = CreatureState.Idle;
            if (inputHelper.KeyboardState.IsKeyDown(KeyBinds.PlayerMoveLeft))
            {
                _playerMovingForce += new Vector2(x: -_baseVelocity, 0);
                _creatureEffect     = SpriteEffects.None | SpriteEffects.FlipVertically;
                CreatureState       = CreatureState.Moving;
            }

            if (inputHelper.KeyboardState.IsKeyDown(KeyBinds.PlayerMoveRight))
            {
                _playerMovingForce += new Vector2(x: _baseVelocity, 0);
                _creatureEffect     = SpriteEffects.FlipHorizontally | SpriteEffects.FlipVertically;
                CreatureState       = CreatureState.Moving;
            }

            if (inputHelper.IsNewKeyPress(KeyBinds.PlayerJump) && !_inAir)
            {
                ObjectBody.ApplyLinearImpulse(new Vector2(0f, 1f));
                CreatureState = CreatureState.Jump;
                if (GameSettings._Volume)
                {
                    SoundEffects.PlayerjumpSoundEffects.Play();
                }
            }

            if (inputHelper.IsNewKeyPress(KeyBinds.PlayerInteract))
            {
                if (_nearInteractable != null)
                {
                    _nearInteractable.Interact(gameTime);
                }
            }

            if (_inAir)
            {
                CreatureState = CreatureState.Jump;
            }

            if (prevState == CreatureState.Attack)
            {
                CreatureState = CreatureState.Attack;
            }
        }
Пример #30
0
    private void OnCollisionStay2D(Collision2D collision)
    {
        Collider2D collider = collision.collider;

        if (collision.collider.tag == "possessable" && state.name == "ghost")
        {
            Debug.Log("Ran into something you can possess");

            Debug.Log("Pressing C?: " + InputManager.Instance.GetPossessionButtonDown_Player1());



            colliderState   = collider.GetComponent <Possessable>().state;
            currentCollider = collider;
        }
    }
Пример #31
0
    public bool MudaAplicaGolpe()
    {
        bool retorno = false;

        if (estado == CreatureState.aPasseio || estado == CreatureState.emLuta || estado == CreatureState.selvagem)
        {
            estado  = CreatureState.aplicandoGolpe;
            retorno = true;
        }
        else
        {
            Debug.LogError("estado indefinido");
        }

        return(retorno);
    }
Пример #32
0
    private TouchData MakeTouchData(UnityEngine.Vector2 position, CreatureState creatureState)
    {
        //are we over an exisiting button
        //for (int index = 0; index < creatureState.CreatureStateHud.uiElementDataArray.Count; ++index)
        //{
        //    var rect = GetWeaponUIRect(uiElementData.position);
        //    if (rect.Contains(position))
        //    {
        //    }
        //}

        return(new TouchData()
        {
            start = position
        });
    }
Пример #33
0
    void Update()
    {
        isPossessionButtonPressed = InputManager.Instance.GetPossessionButtonDown_Player1();

        if (isPossessionButtonPressed)
        {
            Debug.Log("trying to possess");
            if (state.name == "ghost" && colliderState.name != "null")
            {
                Debug.Log("You possessed a " + colliderState.name);

                state = colliderState;
                colliderState.name = "null";
                Destroy(currentCollider.gameObject);
            }

            else if (state.name != "ghost")
            {
                if (state.name == "panda")
                {
                    Instantiate(redpandaprefab, transform.position, Quaternion.identity);
                }
                else if (state.name == "tiger")
                {
                    Instantiate(tigerprefab, transform.position, Quaternion.identity);
                }
                else if (state.name == "crane")

                {
                    Instantiate(craneprefab, transform.position, Quaternion.identity);
                }


                else if (state.name == "koifish")
                {
                    Instantiate(koifishprefab, transform.position, Quaternion.identity);
                }


                state = ghost;
                colliderState.name = "null";

                Debug.Log("You turned back into a ghost");
                //Spawn in the creature that you used to be
            }
        }
    }
Пример #34
0
 public void Read (TProtocol iprot)
 {
   TField field;
   iprot.ReadStructBegin();
   while (true)
   {
     field = iprot.ReadFieldBegin();
     if (field.Type == TType.Stop) { 
       break;
     }
     switch (field.ID)
     {
       case 1:
         if (field.Type == TType.Struct) {
           Header = new ProtocolBase();
           Header.Read(iprot);
         } else { 
           TProtocolUtil.Skip(iprot, field.Type);
         }
         break;
       case 2:
         if (field.Type == TType.I64) {
           ServerTick = iprot.ReadI64();
         } else { 
           TProtocolUtil.Skip(iprot, field.Type);
         }
         break;
       case 3:
         if (field.Type == TType.List) {
           {
             CreatureStates = new List<CreatureState>();
             TList _list0 = iprot.ReadListBegin();
             for( int _i1 = 0; _i1 < _list0.Count; ++_i1)
             {
               CreatureState _elem2;
               _elem2 = new CreatureState();
               _elem2.Read(iprot);
               CreatureStates.Add(_elem2);
             }
             iprot.ReadListEnd();
           }
         } else { 
           TProtocolUtil.Skip(iprot, field.Type);
         }
         break;
       default: 
         TProtocolUtil.Skip(iprot, field.Type);
         break;
     }
     iprot.ReadFieldEnd();
   }
   iprot.ReadStructEnd();
 }
Пример #35
0
    private void SetState(CreatureState state)
    {
        Vehicle.MaxSpeed = OriginalSpeed;
        Vehicle.TurnTime = OriginalTurnTime;
        _state = state;
        switch (_state){
        case CreatureState.Neutral:
            _renderer.material = _baseMaterial;
            _renderer.material.color = Color.white;

            break;
        case CreatureState.Prey:
            Vehicle.MaxSpeed *= 1.75f;
            Vehicle.TurnTime *= 0.95f;
            _renderer.material = _preyMaterial;
            _renderer.material.color = Color.yellow;
            break;
        case CreatureState.Pursuer:
            Vehicle.MaxSpeed *= 2f;
            _renderer.material.color = Color.red;
            break;
        }
        ForPursuit.enabled = State == CreatureState.Pursuer;
        ForWander.enabled = State == CreatureState.Neutral;
        ForNeighbors.enabled = State != CreatureState.Prey;
        ForEvasion.enabled = State == CreatureState.Prey;
        Trail.enabled = State == CreatureState.Prey;
    }