public override SoldierStateBase NextState(GameObject gameObject, AnimatorHandler animatorHandler, StateContex contex)
        {
            //float h = (float) contex.Get(DTSAnimation.BLEND_TREE_2D_PARAM_NAME_1);
            //float v = (float) contex.Get(DTSAnimation.BLEND_TREE_2D_PARAM_NAME_2);

            //animatorHandler.animator.SetFloat(DTSAnimation.BLEND_TREE_2D_PARAM_NAME_1, h);
            //animatorHandler.animator.SetFloat(DTSAnimation.BLEND_TREE_2D_PARAM_NAME_2, v);

            if (contex.Check(EContexParam.BEGIN_RUN))
            {
                soldierStateRun.Enter(gameObject, animatorHandler, contex);
                return(soldierStateRun);
            }

            if (contex.Check(EContexParam.BEGIN_CROUCH))
            {
                soldierStateCrouch.Enter(gameObject, animatorHandler, contex);
                return(soldierStateCrouch);
            }

            if (contex.Check(EContexParam.DUMP) && dump.CheckAndRun())
            {
                contex.preState = soldierStateWalk;
                soldierStateJump.Enter(gameObject, animatorHandler, contex);
                return(soldierStateJump);
            }

            return(soldierStateWalk);
        }
Exemple #2
0
 private void Awake()
 {
     //healthbar = FindObjectOfType<HealthBar>();
     staminabar      = FindObjectOfType <StaminaBar>();
     animatorHandler = GetComponentInChildren <AnimatorHandler>();
     levelLoader     = FindObjectOfType <LevelLoader>();
 }
Exemple #3
0
        // 射击 times 次,每次开火间隔 delay
        private IEnumerator MultiFire(int times, float delay, AnimatorHandler animatorHandler, CharacterType characterType)
        {
            float lastTime = Time.time;

            Fire(animatorHandler, characterType, false);
            animatorHandler.animator.SetTrigger(DTSAnimation.SHOOT_BURST);

            times--;
            if (times > 0)
            {
                while (true)
                {
                    float nowTime = Time.time;

                    if (nowTime - lastTime > delay)
                    {
                        lastTime = nowTime;
                        times--;
                        Fire(animatorHandler, characterType, false);

                        if (times == 0)
                        {
                            break;
                        }
                    }
                    yield return(null);
                }
            }
        }
Exemple #4
0
    internal void Init(Mission mis)
    {
        this.mis = mis;

        // check once for all instances, cause these references are static for all panels
        if (missionsCMan == null)
        {
            goldPileSprites = Resources.LoadAll <Sprite>("Items/Gold").ToList();
            missionsCMan    = UIManager.i.panels.missionPanel.GetComponent <CanvasManager>();
            detailsCanvas   = missionsCMan.controlledCanvases.Find(canvas => canvas.name.Contains("Details"));
            overviewCanvas  = UIManager.i.panels.missionPreviewContentPanel.GetComponent <Canvas>();
        }

        //auto-assign some references
        animatorLocation = locationImage.transform.parent.GetComponent <Animator>();
        heroTransform    = heroImage.transform.parent;
        animHero         = heroTransform.GetComponent <AnimatorHandler>();
        animHero.animMonitor.AnimationFinished += OnAnimationFinished;
        enemyTransform = enemyImage.transform.parent;
        animEnemy      = enemyTransform.GetComponent <AnimatorHandler>();
        animEnemy.animMonitor.AnimationFinished += OnAnimationFinished;

        // call OnPanelClicked() method when panel is clicked on
        GetComponent <Button>().onClick.AddListener(() => OnPanelClicked(mis));

        MissionEventsSubscription();
        UnitEventsSubscription(mis.hero);

        MissionIntroAnimSetUp();
    }
    private void Awake()
    {
        if (extraHealthActive)
        {
            timer += Time.deltaTime;
            if (timer > extraHealthSpeed)
            {
                extraHealth--;
                extraHealthBar.setCurrentHealth(extraHealth);
                timer = 0;
            }
        }

        if (contadorMonedasActive)
        {
            timerMonedas += Time.deltaTime;
            if (timerMonedas > tiempoContadorMonedasActivo)
            {
                BarraMonedas.SetActive(false);
                timerMonedas = 0;
            }
        }

        if (FLAGcontadorMonedasActive)
        {
            timerMonedas              = 0;
            contadorMonedasActive     = true;
            FLAGcontadorMonedasActive = false;
        }

        staminaBar      = FindObjectOfType <StaminaBar>();
        animatorHandler = GetComponentInChildren <AnimatorHandler>();
    }
        public override void Enter(GameObject gameObject, AnimatorHandler animatorHandler, StateContex contex)
        {
            Transform weaponMount = Tools.FindChildrenTransform(gameObject, "Bip001 Spine");

            ObjectPoolMgr.Instance.LoadGameObject("model/" + modelName, (obj) =>
            {
                weaponModel = obj;
                RecoverBackup();
                weaponFire = new WeaponFire(camera,
                                            belongSoldierType,
                                            weaponConf.recoilUp,
                                            weaponConf.recoilLeft,
                                            weaponConf.recoilRight,
                                            weaponConf.horizontalRevert,
                                            weaponConf.verticalRevert,
                                            weaponConf.hurt1
                                            );
                weaponFire.SetWeapon(weaponModel);

                obj.name             = modelName;
                obj.transform.parent = weaponMount;

                obj.transform.localScale       = weaponConf.localScale;
                obj.transform.localPosition    = weaponConf.localPosition;
                obj.transform.localEulerAngles = weaponConf.localRotation;

                Transform leftHandIKTransform  = Tools.FindChildrenTransform(gameObject, IKPosition.IKLeftHand);
                Transform rightHandIKTransform = Tools.FindChildrenTransform(gameObject, IKPosition.IKRightHand);

                leftHandIKTransform.localPosition  = weaponConf.leftHandIKPositon;
                rightHandIKTransform.localPosition = weaponConf.rightHandIKPositon;
            });

            animatorHandler.animator.SetInteger(DTSAnimation.WEAPON_PARAM, DTSAnimation.ANIMATION_STATE_WEAPON_INFANTRY);
        }
        public void ReloadBullet(AnimatorHandler animatorHandler)
        {
            if (BulletCountSecond.val == 0)
            {
                MusicMgr.Instance.PlaySound("kake");
                nextAllowUseSkillTime = Time.time * 1000;
                reload.ClearCD();
                return;
            }

            if (BulletCountFirstFull == BulletCountFirst.val)
            {
                return;
            }

            MusicMgr.Instance.PlaySound("reload");
            animatorHandler.PlayAnimation(DTSAnimation.HEAVY_RELOAD, 1);

            MonoMgr.Instance.StartDelayEvent(reload.LockTime, () => {
                int bulletCount = BulletCountFirstFull - BulletCountFirst.val;
                bulletCount     = Math.Min(bulletCount, BulletCountSecond.val);

                BulletCountFirst.val  += bulletCount;
                BulletCountSecond.val -= bulletCount;
            });
        }
Exemple #8
0
        public override void Update(GameObject gameObject, AnimatorHandler animatorHandler, StateContex contex)
        {
            if (nextAllowUseSkillTime > Time.time * 1000)
            {
                return;
            }

            if (contex.Check(EContexParam.SHOOT) && leftAttack.CheckAndRun())
            {
                LeftAttack(animatorHandler);

                if (contex.characterType == Entity.CharacterType.PLAYER)
                {
                    EventMgr.Instance.EventTrigger(EventName.PLAYER_KNIFE_ATTACK, 30);
                }
                return;
            }

            if (contex.Check(EContexParam.SHOOT_BURST) && rightAttack.CheckAndRun())
            {
                RightAttack(animatorHandler);

                if (contex.characterType == Entity.CharacterType.PLAYER)
                {
                    EventMgr.Instance.EventTrigger(EventName.PLAYER_KNIFE_ATTACK, 60);
                }
                return;
            }
        }
        public override void Update(GameObject gameObject, AnimatorHandler animatorHandler, StateContex contex)
        {
            if (nextAllowUseSkillTime > Time.time * 1000)
            {
                return;
            }

            // 换子弹
            if (contex.Check(EContexParam.RELOAD) && reload.CheckAndRun())
            {
                nextAllowUseSkillTime = Time.time * 1000 + reload.LockTime;
                ReloadBullet(animatorHandler);
                return;
            }

            // 单发射击
            if (contex.Check(EContexParam.SHOOT))
            {
                if (BulletCountFirst.val >= 1 && shoot.CheckAndRun())
                {
                    nextAllowUseSkillTime = Time.time * 1000 + shoot.LockTime;
                    Fire(animatorHandler, contex.characterType);
                    return;
                }
            }
        }
Exemple #10
0
        public override void Enter(GameObject gameObject, AnimatorHandler animatorHandler, StateContex contex)
        {
            Transform weaponMount = Tools.FindChildrenTransform(gameObject, "Bip001 Spine");

            ObjectPoolMgr.Instance.LoadGameObject("model/" + modelName, (obj) =>
            {
                weaponModel = obj;

                obj.name             = modelName;
                obj.transform.parent = weaponMount;

                obj.transform.localScale       = weaponConf.localScale;
                obj.transform.localPosition    = weaponConf.localPosition;
                obj.transform.localEulerAngles = weaponConf.localRotation;

                Transform leftHandIKTransform  = Tools.FindChildrenTransform(gameObject, IKPosition.IKLeftHand);
                Transform rightHandIKTransform = Tools.FindChildrenTransform(gameObject, IKPosition.IKRightHand);

                if (leftHandIKTransform)
                {
                    leftHandIKTransform.localPosition = weaponConf.leftHandIKPositon;
                }
                if (rightHandIKTransform)
                {
                    rightHandIKTransform.localPosition = weaponConf.rightHandIKPositon;
                }
            });
            animatorHandler.animator.SetInteger(DTSAnimation.WEAPON_PARAM, DTSAnimation.ANIMATION_STATE_WEAPON_KNIFE);
        }
Exemple #11
0
 private void Awake()
 {
     animatorHandler = GetComponentInChildren <AnimatorHandler>();
     inputHandler    = GetComponent <InputHandler>();
     cards           = this.GetComponent <CardsContainer>();
     //Time.timeScale = 0.2f;
     //anim = GetComponentInChildren<Animator>();
 }
Exemple #12
0
 void Start()
 {
     animatorHandler    = GetComponent <AnimatorHandler>();
     transform.position = Map.instance.TileCoordToWorldCoord(posX, posY);
     curHp          = maxHp;
     movementPoints = maxMovementPoints;
     actionPoints   = maxActionPoints;
 }
Exemple #13
0
    public override void AttemptToCastSpell(AnimatorHandler animatorHandler, PlayerStats playerStats, WeaponSlotManager weaponSlotManager)
    {
        base.AttemptToCastSpell(animatorHandler, playerStats, weaponSlotManager);
        GameObject instantiateWarmUpSpellFX = Instantiate(spellWarmUpFX, weaponSlotManager.rightHandSlot.transform);

        //instantiateWarmUpSpellFX.gameObject.transform.localScale = new Vector3(100, 100, 100);
        animatorHandler.PlayTargetAnimation(spellAnimation, true);
    }
Exemple #14
0
 private void Awake()
 {
     playerAttacker  = GetComponentInChildren <PlayerAttacker>();
     playerInventory = GetComponent <PlayerInventory>();
     playerStats     = GetComponent <PlayerStats>();
     cameraHandler   = FindObjectOfType <CameraHandler>();
     animatorHandler = GetComponentInChildren <AnimatorHandler>();
     playerManager   = GetComponent <PlayerManager>();
 }
Exemple #15
0
        bool precMovY = true; // true si en haut

        void Start()
        {
            rigidbody       = GetComponent <Rigidbody>();
            inputHadler     = GetComponent <InputHandler>();
            animatorHandler = GetComponentInChildren <AnimatorHandler>();
            cameraObject    = Camera.main.transform;
            mytransform     = transform;
            animatorHandler.Initialize();
        }
Exemple #16
0
    public override void AttemptToConsumeItem(AnimatorHandler playerAnimatorManager, WeaponSlotManager weaponSlotManager, PlayerEffectsManager playerEffectsManager)
    {
        base.AttemptToConsumeItem(playerAnimatorManager, weaponSlotManager, playerEffectsManager);
        GameObject flask = Instantiate(itemModel, weaponSlotManager.leftHandSlot.transform); //instanciamos el modelo del item en la mano derecha

        playerEffectsManager.currentParticleFX   = recoveryFX;                               //le pasamos el fx
        playerEffectsManager.amountToBeHealed    = healthRecoverAmount;                      //le pasamos la vida que le tiene que sumar
        playerEffectsManager.instantiatedFXModel = flask;
        weaponSlotManager.leftHandSlot.UnloadWeapon();                                       //ocultamos arma en la mano para poner el item consumible
    }
Exemple #17
0
 private void Awake()
 {
     cameraHandler     = FindObjectOfType <CameraHandler>();
     animatorHandler   = GetComponent <AnimatorHandler>();
     weaponSlotManager = GetComponent <WeaponSlotManager>();
     playerManager     = GetComponentInParent <PlayerManager>();
     inputHandler      = GetComponentInParent <InputHandler>();
     playerInventory   = GetComponentInParent <PlayerInventory>();
     playerStats       = GetComponentInParent <PlayerStats>();
 }
Exemple #18
0
    private void Awake()
    {
        //dejar esto en el awake si se cambia de lugar lo de abajo
        cameraHolder = FindObjectOfType <CameraHolder>();

        playerManager   = GetComponent <PlayerManager>();
        playerStats     = GetComponent <PlayerStats>();
        rigidbody       = GetComponent <Rigidbody>();
        inputHandler    = GetComponent <InputHandler>();
        animatorHandler = GetComponentInChildren <AnimatorHandler>();
    }
Exemple #19
0
        public override void Enter(GameObject gameObject, AnimatorHandler animatorHandler, StateContex contex)
        {
            string animation = contex.weapon.GetStandAnimationName();

            if (animation != string.Empty)
            {
                animatorHandler.animator.SetInteger(DTSAnimation.POSE_PARAM, DTSAnimation.ANIMATION_STATE_STAND);
                animatorHandler.PlayAnimation(animation, 0);
                animatorHandler.PlayAnimation(animation, 1);
            }
        }
 private void Start()
 {
     walk            = GetComponent <Walk>();
     fly             = GetComponent <Flying>();
     currentMovement = walk;
     currentMovement.SetCurrentRotation(new Vector3(0, 0, 0));
     flightStamina     = new Timer(startStaminaValue);
     controller        = GetComponent <CharacterController>();
     anim              = GetComponent <AnimatorHandler>();
     dist              = GetComponent <Distance>();
     flySafeStartTimer = new Timer(flySafeStart);
 }
        public override void Enter(GameObject gameObject, AnimatorHandler animatorHandler, StateContex contex)
        {
            string animation = contex.weapon.GetCrouchAnimationName();

            if (animation != string.Empty)
            {
                // 设置角色姿态 为 蹲下
                animatorHandler.animator.SetInteger(DTSAnimation.POSE_PARAM, DTSAnimation.ANIMATION_STATE_CROUCH);
                // 播放使用 该武器类型 的 站立动画
                animatorHandler.PlayAnimation(animation, 0);
                animatorHandler.PlayAnimation(animation, 1);
            }
        }
Exemple #22
0
    void Start()
    {
        playerManager   = GetComponent <PlayerManager>();
        rigidbody       = GetComponent <Rigidbody>();
        inputHandler    = GetComponent <InputHandler>();
        animatorHandler = GetComponentInChildren <AnimatorHandler>();
        cameraObject    = Camera.main.transform;
        myTransform     = transform;
        animatorHandler.Initialize();

        playerManager.isGrounded = true;
        ignoreForGroundCheck     = ~(1 << 7 | 1 << 11); //We could just set the Layer directly
    }
        public override void Update(GameObject gameObject, AnimatorHandler animatorHandler, StateContex contex)
        {
            if (nextAllowUseSkillTime > Time.time * 1000)
            {
                return;
            }

            // 换子弹
            if (contex.Check(EContexParam.RELOAD) && reload.CheckAndRun())
            {
                nextAllowUseSkillTime = Time.time * 1000 + reload.LockTime;
                ReloadBullet(animatorHandler);
                return;
            }

            // 单发射击
            if (contex.Check(EContexParam.SHOOT))
            {
                if (BulletCountFirst.val >= 1 && shoot.CheckAndRun())
                {
                    nextAllowUseSkillTime = Time.time * 1000 + shoot.LockTime;
                    Fire(animatorHandler, contex.characterType);
                    return;
                }
            }

            // 三发射击
            if (contex.Check(EContexParam.SHOOT_BURST))
            {
                if (BulletCountFirst.val >= 3 && shootBrush.CheckAndRun())
                {
                    MonoMgr.Instance.StartCoroutine(MultiFire(3, 0.1f, animatorHandler, contex.characterType));
                    nextAllowUseSkillTime = Time.time * 1000 + shootBrush.LockTime;
                    return;
                }
            }

            if (contex.Check(EContexParam.SHOOT_LINE) && shootLine.CheckAndRun() && camera != null)
            {
                if (Physics.Raycast(camera.transform.position, camera.transform.forward, out RaycastHit hit, Mathf.Infinity))
                {
                    EventMgr.Instance.EventTrigger(EventName.ATTACK_YUN, new SkillAttackYunBullet
                    {
                        position = weaponModel.transform.position,
                        direct   = hit.point - weaponModel.transform.position,
                        force    = 100,
                    });
                }
            }
        }
Exemple #24
0
 public virtual void AttemptToConsumeItem(AnimatorHandler playerAnimatorManager, WeaponSlotManager weaponSlotManager, PlayerEffectsManager playerEffectsManager)
 {
     if (currentItemAmount > 0 && maxItemAmount >= currentItemAmount) //si tiene items que consumir
     {
         //hacer animacion
         playerAnimatorManager.PlayTargetAnimation(consumeAnimation, isInteracting);
         currentItemAmount = currentItemAmount - 1;
     }
     else
     {
         //hacer animacion de que no tiene mas consumibles , deteniendo al player un instante
         //playerAnimatorManager.PlayTargetAnimation("Shrug", true);
     }
 }
Exemple #25
0
    private void Start()
    {
        playerManager   = GetComponent <PlayerManager>(); // fall stuff
        rigidbody       = GetComponent <Rigidbody>();
        inputHandler    = GetComponent <InputHandler>();
        cameraObject    = Camera.main.transform;
        myTransform     = transform;
        animatorHandler = GetComponentInChildren <AnimatorHandler>();
        animatorHandler.Initialize();

        playerManager.isGrounded = true; // fall stuff
        ignoreForGroundCheck     = ~(1 << 9 | 1 << 11);

        Physics.IgnoreCollision(characterCollider, characterCollisionBlockerCollider);
    }
Exemple #26
0
        public override SoldierStateBase NextState(GameObject gameObject, AnimatorHandler animatorHandler, StateContex contex)
        {
            if (contex.Check(EContexParam.END_RUN))
            {
                soldierStateWalk.Enter(gameObject, animatorHandler, contex);
                return(soldierStateWalk);
            }

            if (contex.Check(EContexParam.DUMP) && dump.CheckAndRun())
            {
                contex.preState = soldierStateRun;
                soldierStateJump.Enter(gameObject, animatorHandler, contex);
                return(soldierStateJump);
            }
            return(soldierStateRun);
        }
Exemple #27
0
 void Start()
 {
     cam        = Camera.main;
     viewVisual = true;
     skillWheelPanel.SetActive(false);
     currentSkill = skills[0];
     baseColor    = skillsImg[0].color;
     anim         = GetComponentInChildren <AnimatorHandler>();
     cards        = FindObjectOfType <CardsContainer>();
     if (FindObjectOfType <PlayerPassives>() != null)
     {
         foreach (var item in skills)
         {
             item.cooldownTime = item.cooldownTime - (item.cooldownTime * PlayerPassives.instance.cooldownBonus);
         }
     }
 }
    private void Awake()
    {
        playerAttacker  = GetComponent <PlayerAttacker>();
        playerInventory = GetComponent <PlayerInventory>();
        playerManager   = GetComponent <PlayerManager>();
        tutorial        = FindObjectOfType <tutorialHandler>();

        playerEffectsManager  = GetComponentInChildren <PlayerEffectsManager>();
        playerAnimatorManager = GetComponentInChildren <AnimatorHandler>();
        weaponSlotManager     = GetComponentInChildren <WeaponSlotManager>();

        playerLocomotion = GetComponent <PlayerLocomotion>();
        playerStats      = GetComponent <PlayerStats>();
        cameraHolder     = FindObjectOfType <CameraHolder>();
        UIManager        = FindObjectOfType <UIManager>();
        help_input       = false;
    }
        public void Fire(AnimatorHandler animatorHandler, CharacterType characterType, bool enterAnimation = true)
        {
            if (BulletCountFirst.val > 0)
            {
                BulletCountFirst.val -= 1;
                MusicMgr.Instance.PlaySound("fire");
                weaponFire.Tick(characterType);

                if (enterAnimation)
                {
                    animatorHandler.animator.SetTrigger(DTSAnimation.SHOOT);
                }
            }
            else
            {
                //MusicMgr.Instance.PlaySound("kake");
            }
        }
Exemple #30
0
    private void Awake()
    {
        playerAttacker  = GetComponent <PlayerAttacker>();
        playerInventory = GetComponent <PlayerInventory>();
        playerManager   = GetComponent <PlayerManager>();
        skillManager    = GetComponent <SkillManager>();
        animHandler     = GetComponentInChildren <AnimatorHandler>();

        if (inputActions == null)
        {
            //We need to Instantiate the Control Asset via Script. It doesnt show in the inspector
            inputActions = new Controls();

            inputActions.Player.Movement.performed += ctx => _movementInput = ctx.ReadValue <Vector2>();
            //inputActions.Player.XYAxis.performed += ctx => _cameraInput = ctx.ReadValue<Vector2>();
        }

        SetCursorState(false, true);
    }