示例#1
0
    private void ModifyHitbox(Hitbox_Render _renderBox, Hitbox_Gameplay _hbox_gameplay, bool _p1, GameState _gameState)
    {
        float y = CharacterHeight;
        float z = 1;

        if (_hbox_gameplay.HitboxType == GameplayEnums.HitboxType.Hitbox_Attack)
        {
            y /= 2f;
            z  = 2;
        }

        Vector3 pos   = GetInGamePosition(_hbox_gameplay, _p1, _gameState);
        Vector3 scale = new Vector3(GameUnitsToUnityUnits(_hbox_gameplay.Width), y, z);

        _renderBox.ObjectInGame.transform.position   = pos;
        _renderBox.ObjectInGame.transform.localScale = scale;
        if (_hbox_gameplay.AttackAttribute == GameplayEnums.AttackAttribute.Low)
        {
            _renderBox.ObjectInGame.transform.position = pos - new Vector3(0, y / 2f, 2f);
            //_renderBox.ObjectInGame.transform.localScale = new Vector3(scale.x, scale.y / 2f);
        }
        _renderBox.StillExists = true;
    }
示例#2
0
    private void CreateNewHitbox(Hitbox_Gameplay _hbox_gameplay, bool _p1, GameState _gameState)
    {
        Hitbox_Render _renderBox = new Hitbox_Render();

        _renderBox.ReferenceBox = _hbox_gameplay;
        _renderBox.ObjectInGame = GameObject.CreatePrimitive(PrimitiveType.Cube);
        ModifyHitbox(_renderBox, _hbox_gameplay, _p1, _gameState);
        switch (_hbox_gameplay.HitboxType)
        {
        case GameplayEnums.HitboxType.Hitbox_Attack:
        case GameplayEnums.HitboxType.Hitbox_Throw:
            if (_p1)
            {
                _renderBox.ObjectInGame.GetComponent <Renderer>().material = P1_Active;
            }
            else
            {
                _renderBox.ObjectInGame.GetComponent <Renderer>().material = P2_Active;
            }
            break;

        case GameplayEnums.HitboxType.Hurtbox_Limb:
        case GameplayEnums.HitboxType.Hurtbox_Main:
            GameplayEnums.CharacterState currentCharacterState;
            if (_p1)
            {
                currentCharacterState = _gameState.P1_State;
            }
            else
            {
                currentCharacterState = _gameState.P2_State;
            }
            Material toSet;
            GameplayEnums.CharacterState cstate = currentCharacterState;
            if (cstate == GameplayEnums.CharacterState.Special)
            {
                if (_p1)
                {
                    cstate = _gameState.P1_CState.SelectedCharacter.GetEquivalentState();
                }
                else
                {
                    cstate = _gameState.P2_CState.SelectedCharacter.GetEquivalentState();
                }
            }
            switch (cstate)
            {
            case GameplayEnums.CharacterState.AttackActive:
            case GameplayEnums.CharacterState.AttackStartup:
            case GameplayEnums.CharacterState.ThrowActive:
            case GameplayEnums.CharacterState.ThrowStartup:
                if (_p1)
                {
                    toSet = P1_Startup;
                }
                else
                {
                    toSet = P2_Startup;
                }
                break;

            case GameplayEnums.CharacterState.AttackRecovery:
            case GameplayEnums.CharacterState.Blockstun:
            case GameplayEnums.CharacterState.Clash:
            case GameplayEnums.CharacterState.ThrowBreak:
            case GameplayEnums.CharacterState.ThrowRecovery:
                if (_p1)
                {
                    toSet = P1_Recovery;
                }
                else
                {
                    toSet = P2_Recovery;
                }
                break;

            default:
                if (_p1)
                {
                    toSet = P1_Character;
                }
                else
                {
                    toSet = P2_Character;
                }
                break;
            }
            _renderBox.ObjectInGame.GetComponent <Renderer>().material = toSet;
            break;
        }
        m_activeHitboxes.Add(_renderBox);
    }