Example #1
0
    private StanceSetting?GetStanceSettingForType(StanceType positionType)
    {
        StanceSetting[] stanceSettings = null;
        switch (currentState)
        {
        case BodyState.IDLE:
        case BodyState.ATTACK_WARMUP:
            stanceSettings = idleStanceSettings;
            break;

        case BodyState.ATTACKING:
            stanceSettings = attackingStanceSettings;
            break;

        default:
            Debug.LogWarning($"Unknown state {currentState}");
            return(null);
        }

        foreach (var positionSetting in stanceSettings)
        {
            if (positionSetting.stanceType == positionType)
            {
                return(positionSetting);
            }
        }

        Debug.LogError($"Can't find hand setting for type {positionType}");
        return(null);
    }
Example #2
0
    private StanceType GetRandomStance(StanceType previousStance)
    {
        Array values = Enum.GetValues(typeof(StanceType));

        System.Random random    = new System.Random();
        StanceType    newStance = previousStance;

        while (previousStance == newStance)
        {
            newStance = (StanceType)values.GetValue(random.Next(values.Length));
        }
        return(newStance);
    }
Example #3
0
    private IEnumerator ChoosePosionRoutine()
    {
        float stanceChooseDuration = GetAdjastedConfigValue(aiConfig.stanceChooseDurationDefault, aiConfig.stanceChooseDurationMin);
        float finishTime           = Time.time + stanceChooseDuration;

        while (Time.time < finishTime)
        {
            float stanceChooseDelay = GetAdjastedConfigValue(aiConfig.stanceChooseDelayDefault, aiConfig.stanceChooseDelayMin);
            yield return(new WaitForSeconds(stanceChooseDelay));

            StanceType randomStance = GetRandomStance(prevStanceType);
            prevStanceType = randomStance;
            body.SetStance(randomStance);

            float stancePostChoiceDelay = GetAdjastedConfigValue(aiConfig.stancePostChoiceDelayDefault, aiConfig.stancePostChoiceDelayMin);
            yield return(new WaitForSeconds(stancePostChoiceDelay));
        }
    }
Example #4
0
    void HandleStanceSwitch()
    {
        if (stanceSwitchCooldownTimer > 0)
        {
            return;
        }
        StanceType prevStance = stance;

        if (Input.GetKeyDown(KeyCode.Q))
        {
            stance = StanceType.winter;
        }
        else if (Input.GetKeyDown(KeyCode.W))
        {
            stance = StanceType.spring;
        }
        else if (Input.GetKeyDown(KeyCode.E))
        {
            stance = StanceType.summer;
        }
        else if (Input.GetKeyDown(KeyCode.R))
        {
            stance = StanceType.fall;
        }
        if (stance != prevStance)
        {
            if (prevStance == StanceType.summer)
            {
                AudioManager.singleton.TurnOffLoop();
            }
            AudioManager.singleton.PlaySoundEffect(stanceSFX, .3f);
            if (fireConePrefab.activeInHierarchy)
            {
                fireConePrefab.SetActive(false);
            }
            controller.anim.SetBool("isCastingLoop", false);
            smokeParticles.emissionRate = 0;
            UpdateStance(stance);
            stanceSwitchCooldownTimer = stanceSwitchCooldown;
        }
    }
Example #5
0
    void UpdateStance(StanceType stance)
    {
        switch (stance)
        {
        case StanceType.winter:
            sprite.color = Color.cyan;
            break;

        case StanceType.spring:
            sprite.color = Color.green;
            break;

        case StanceType.summer:
            sprite.color = Color.red;
            break;

        case StanceType.fall:
            sprite.color = Color.yellow;
            break;
        }
    }
Example #6
0
    private void AIController_OnAttack(StanceType aiAttackStance)
    {
        bool blockSuccess = userBody.CurrentStance == aiAttackStance;

        userBody.BlockFinished(blockSuccess);


        if (blockSuccess)
        {
            print($"Player is not hit");
            userBlockCombo++;
        }
        else
        {
            userBlockCombo = 0;
            print($"Player is hit");
        }
        aiController.UpdateDifficulty(userBlockCombo);

        OnUserBlock(userBlockCombo);
    }
Example #7
0
    private void OnStanceChanged(StanceType newStance)
    {
        idleArm.transform.DOKill(true);
        attackingArm.transform.DOKill(true);

        StanceSetting?positionSetting = GetStanceSettingForType(newStance);

        if (positionSetting.HasValue)
        {
            Vector3 armTargetPosition = new Vector3(positionSetting.Value.armOffsetX, positionSetting.Value.armOffsetY);
            Vector3 armTargetRotation = new Vector3(0, 0, positionSetting.Value.armRotationZ);
            if (currentState != BodyState.ATTACKING)
            {
                CurrentArm.transform.DOLocalMove(armTargetPosition, animationCfg.bodyStanceChangeDuration).SetEase(animationCfg.bodyStanceChangeEase);
                CurrentArm.transform.DOLocalRotate(armTargetRotation, animationCfg.bodyStanceChangeDuration).SetEase(animationCfg.bodyStanceChangeEase);
            }
            else
            {
                CurrentArm.transform.localRotation = Quaternion.Euler(armTargetRotation);
                CurrentArm.transform.localPosition = armTargetPosition;
            }
        }
    }
Example #8
0
 public void SetStance(StanceType newStance)
 {
     CurrentStance = newStance;
     OnStanceChanged(CurrentStance);
 }
Example #9
0
 public Stance(StanceType initialStance)
 {
     this.current  = initialStance;
     this.previous = initialStance;
 }
 public SquadronStanceDefinition()
 {
     this.stanceTypeField = StanceType.Undefined;
     this.initialMainMissionIndexField     = -1;
     this.initialMainMissionTaskIndexField = 0;
 }
Example #11
0
 public weapon(string Name, Texture2D Bolt_Back, Texture2D Bolt_Forward, Texture2D Clip, Texture2D[] MuzzleFlash, Vector2 grip, Vector2 muzzle, Vector2 clip_pos, Vector2 action,
                      ProjectileType PType, StanceType stance, int ClipSize, float Inaccuracy, float Wear, int ROF, bool Auto)
 {
     bolt_back = Bolt_Back;
     bolt_forward = Bolt_Forward;
     clip = Clip;
     item_pos = Vector2.Zero;
     muzzPos = muzzle;
     muzzleFlash = MuzzleFlash;
     clipPos = clip_pos;
     gripPos = grip;
     actionPos = action;
     Pt = PType;
     clipSize = ClipSize;
     clipCurrent = 0;
     inaccuracy = Inaccuracy;
     wear = Wear;
     ROFdelay = ROF;
     timeWaited = 0;
     auto = Auto;
     reloading = shooting = jammed = false;
     name = Name;
     mass = 4;
     angle = 0;
     Stance = StanceType.unarmed;
 }
Example #12
0
    void stanceShift(bool shiftRight)
    {
        if (stanceCooldown == 2f)
        {
            if (shiftRight == true)
            {
                temp           = current_stance;
                current_stance = right_stance;
                //right_stance = left_stance;
                right_stance = temp;
                left_stance  = temp;


                /*
                 * tempStance = currentStance
                 * currentStance = rightStance
                 * rightStance = leftStance
                 * leftStance = tempStance
                 */
            }
            else
            {
                temp = current_stance;
                //current_stance = left_stance;
                current_stance = right_stance;
                //left_stance = right_stance;
                left_stance  = temp;
                right_stance = temp;

                /*
                 * tempStance = currentStance
                 * currentStance = leftStance
                 * leftStance = rightStance
                 * rightStance = tempStance
                 *
                 */
            }

            switch (current_stance)
            {
            case StanceType.mystic:
                hatTexture = Resources.Load("witch_hat_NRM") as Texture2D;
                hat.GetComponent <Renderer>().material.mainTexture = hatTexture;
                coatTexture = Resources.Load("witch_coat_NRM") as Texture2D;
                coat.GetComponent <Renderer>().material.mainTexture = coatTexture;
                hipsTexture = Resources.Load("witch_hips_NRM") as Texture2D;
                hips.GetComponent <Renderer> ().material.mainTexture = hipsTexture;
                legsTexture = Resources.Load("witch_legs_NRM") as Texture2D;
                legs.GetComponent <Renderer> ().material.mainTexture = legsTexture;



                hammerCollider.SetActive(false);
                hammer.SetActive(false);
                swordL.SetActive(true);
                swordR.SetActive(true);
                //print ("mystic");
                lightStance.color = Color.cyan;
                stanceDamage      = 1f;
                distance          = 11f;
                //anim.Play ("dualSwords_idle", -1, 0f);


                break;

            case StanceType.instinct:
                hammerCollider.SetActive(false);
                hammer.SetActive(false);
                swordL.SetActive(false);
                swordR.SetActive(false);
                //print ("instinct");
                lightStance.color = Color.yellow;
                stanceDamage      = .5f;
                distance          = 6f;
                break;

            case StanceType.valor:
                //print ("valor");
                hatTexture = Resources.Load("witch_hat_DIFF") as Texture2D;
                hat.GetComponent <Renderer>().material.mainTexture = hatTexture;
                coatTexture = Resources.Load("witch_coat_DIFF") as Texture2D;
                coat.GetComponent <Renderer>().material.mainTexture = coatTexture;
                hipsTexture = Resources.Load("witch_hips_DIFF") as Texture2D;
                hips.GetComponent <Renderer> ().material.mainTexture = hipsTexture;
                legsTexture = Resources.Load("witch_legs_DIFF") as Texture2D;
                legs.GetComponent <Renderer> ().material.mainTexture = legsTexture;

                hammerCollider.SetActive(true);
                hammer.SetActive(true);
                swordL.SetActive(false);
                swordR.SetActive(false);
                lightStance.color = Color.red;
                stanceDamage      = 2.5f;
                distance          = 6f;
                //anim.Play ("hammer_idle", -1, 0f);

                break;
            }

            anim.SetInteger("comboCount", 1);
            stanceCooldown = 0f;
        }
    }