コード例 #1
0
    public void Init(PlayerController pl)
    {
        player          = pl;
        blinkController = player.GetComponent <BlinkController>();

        animator = player.GetComponent <Animator>();

        hexagons = new List <HexagonController>();

        specialAttackDetector = player.specialDetector;
        specialAttackDetector.GetComponent <PlayerSpecialAttackDetector>().Blackboard = this;
        specialAttackDetector.GetComponent <SphereCollider>().radius = player.specialAttackAffectationRadius;

        dashPSRotator = player.transform.Find("ParticleSystems/DashPSRotation");

        if (InputManager.Devices.Count >= player.Id)
        {
            controller = InputManager.Devices[player.Id - 1];
        }

        spawningState        = new PlayerSpawningState();
        idleState            = new PlayerIdleState();
        longIdleState        = new PlayerLongIdleState();
        movingState          = new PlayerMovingState();
        dashingState         = new PlayerDashingState();
        speedBumpState       = new PlayerSpeedBumpState();
        specialState         = new PlayerSpecialState();
        receivingDamageState = new PlayerReceivingDamageState();
        pushedState          = new PlayerPushedState();
        fallingState         = new PlayerFallingState();
        dyingState           = new PlayerDyingState();
        blockedState         = new PlayerBlockedState();
        invisibleState       = new PlayerInvisibleState();
        levelClearedState    = new PlayerLevelClearedState();

        spawningState.Init(this);
        idleState.Init(this);
        longIdleState.Init(this);
        movingState.Init(this);
        dashingState.Init(this);
        speedBumpState.Init(this);
        specialState.Init(this);
        receivingDamageState.Init(this);
        pushedState.Init(this);
        fallingState.Init(this);
        dyingState.Init(this);
        blockedState.Init(this);
        invisibleState.Init(this);
        levelClearedState.Init(this);

        string playerStr = "";

        switch (player.Id)
        {
        case 1: playerStr = "P1"; break;

        case 2: playerStr = "P2"; break;
        }

        moveHorizontal = playerStr + "_Horizontal";
        moveVertical   = playerStr + "_Vertical";
        aimHorizontal  = playerStr + "_AimHorizontal";
        aimVertical    = playerStr + "_AimVertical";
        fire           = playerStr + "_Fire";
        dash           = playerStr + "_Dash";
        special        = playerStr + "_Special";
        greenButton    = playerStr + "_Green";
        redButton      = playerStr + "_Red";
        blueButton     = playerStr + "_Blue";
        yellowButton   = playerStr + "_Yellow";

        playerRayCastMask  = LayerMask.GetMask(playerStr + "RayCast");
        playerPhysicsLayer = LayerMask.NameToLayer("Player");
        enemyPhysicsPlayer = LayerMask.NameToLayer("Enemy");

        ResetLifeVariables();
    }
コード例 #2
0
    //Unity methods
    void Awake()
    {
        Debug.Log("Player " + playerId + " created.");
        rend = GetComponentInChildren<Renderer>();
        ctrl = GetComponent<CharacterController>();
        voxelization = GetComponent<VoxelizationClient>();

        spawningState = new PlayerSpawningState();
        idleState = new PlayerIdleState();
        longIdleState = new PlayerLongIdleState();
        movingState = new PlayerMovingState();
        dashingState = new PlayerDashingState();
        specialState = new PlayerSpecialState();
        swingingState = new PlayerSwingingState();
        receivingDamageState = new PlayerReceivingDamageState();
        fallingState = new PlayerFallingState();
        dyingState = new PlayerDyingState();

        spawningState.Init(this);
        idleState.Init(this);
        longIdleState.Init(this);
        movingState.Init(this);
        dashingState.Init(this);
        specialState.Init(this);
        swingingState.Init(this);
        receivingDamageState.Init(this);
        fallingState.Init(this);
        dyingState.Init(this);

        currentState = spawningState;

        string player = "";
        switch (playerId)
        {
            case 1: player = "P1"; break;
            case 2: player = "P2"; break;
        }

        moveHorizontal = player + "_Horizontal";
        moveVertical = player + "_Vertical";
        aimHorizontal = player + "_AimHorizontal";
        aimVertical = player + "_AimVertical";
        fire = player + "_Fire";
        dash = player + "_Dash";
        special = player + "_Special";

        playerRayCastMask = LayerMask.GetMask(player + "RayCast");
        animator = GetComponent<Animator>();
    }