示例#1
0
    // Start is called before the first frame update
    void Start()
    {
        lm           = new LegacyManager();
        potionCount  = lm.GetPotion();
        playerHealth = player.GetComponent <Damagable>();
        playerBehave = player.GetComponent <PlayerBehaviours>();


        if (potionText != null)
        {
            potionText.text = "X " + potionCount;
        }

        if (player == null)
        {
            return;
        }
        playerHealth.maxHealth = lm.GetMaxHealth();
        playerHealth.SetHealth(lm.GetCurrentHealth());


        //player.GetComponent<Damager>().damage = lm.GetDamage();
        playerBehave.attackDelay  = lm.GetAttackSpeed();
        playerBehave.maxArrowAmmo = lm.GetMaxArrow();

        if (playerBehave.ammoBar != null)
        {
            playerBehave.ammoBar.maxValue = lm.GetMaxArrow();
            playerBehave.ammoBar.value    = lm.GetMaxArrow();
        }
    }
示例#2
0
 public PlayerHandBehaviours(PlayerBehaviours abb, PropHandler ph, FBIKChain hc, IKEffector iKEffector) : base(abb, ph)
 {
     handChain    = hc;
     hp           = ac.humanoidParts;
     handEffector = iKEffector;
     //Muscle handMuscle = ph.attachedMuscleGroup.muscles[ph.attachedMuscleGroup.muscles.Length - 1];// 最后一个位置即为 最末尾的 hand 的 muscle
 }
示例#3
0
    public void createPlayer(int inputIndex)
    {
        print("create player.");
        JoinPlayerInfo joinPlayerInfo = new JoinPlayerInfo();

        joinPlayerInfo.inputIndex   = inputIndex;
        joinPlayerInfo.playerNumber = currentPlayerCount + 1;
        joinPlayerInfo.wizardPrefab = defaultWizard;
        GameObject wizardInstance;
        Vector3    spawnPoint = GameObject.Find("Player " + joinPlayerInfo.playerNumber + " spawnPoint").transform.position;

        if (inputEntities[inputIndex].wizardInstance == null)
        {
            wizardInstance = Instantiate(defaultWizard, spawnPoint, Quaternion.identity);
        }
        else
        {
            wizardInstance = inputEntities[inputIndex].wizardInstance;
        }

        if (joinPlayerInfo.playerNumber == 1)
        {
            leaderInputIndex = inputIndex;
            GameObject go = Instantiate(playerOneCrown, wizardInstance.transform.position, Quaternion.identity);
            go.transform.parent = wizardInstance.transform;
        }

        joinPlayerInfo.wizardPrefab = wizardInstance;
        joinPlayerInfo.trans        = wizardInstance.transform;
        //initializes player
        PlayerBehaviours playerBehaviours = wizardInstance.GetComponent <PlayerBehaviours>();

        playerBehaviours.joinPlayer(joinPlayerInfo);
        GameEventManager.instance.joinPlayerEvent(joinPlayerInfo);
    }
示例#4
0
    // Start is called before the first frame update
    void Start()
    {
        shootingCooldown = shootingFrequency;
        InvokeRepeating("ShootingCooldown", 1f, 1f);

        playerShip       = GameObject.FindGameObjectWithTag("Player");
        playerShipScript = playerShip.GetComponent <PlayerBehaviours>();
    }
示例#5
0
 public void InitializePlayerAnimations(PlayerBehaviours playerBehaviours)
 {
     playerSprite                     = transform.Find("playerFeet").GetChild(0).GetComponent <SpriteRenderer>();
     weaponSprite                     = transform.Find("staffPivot").GetChild(1).GetComponent <SpriteRenderer>();
     cursorSprite                     = transform.Find("cursorAnchor").GetChild(0).GetComponent <SpriteRenderer>();
     anim                             = playerSprite.GetComponent <Animator>();
     playerController                 = playerBehaviours.playerController;
     playerEventController            = playerBehaviours.playerEventController;
     playerEventController.rollDodge += playDodgeAnimation;
 }
示例#6
0
 public void initialize(PlayerBehaviours playerBehaviours)
 {
     print("player controller initialize");
     playerEventController = playerBehaviours.playerEventController;
     playerDodgeInfo       = playerBehaviours.wizardData.dodgeInfo;
     this.inputIndex       = playerBehaviours.inputIndex;
     input = ReInput.players.GetPlayer(inputIndex);
     rb    = GetComponent <Rigidbody2D>();
     findLocations();
     playerAnimations = playerBehaviours.playerAnimations;
     subscribeToEvents();
 }
示例#7
0
    // 消息函数
    public override void Init(ActorManager am)
    {
        base.Init(am);
        // 变量初始化
        HumanoidParts temp = new HumanoidParts(am.puppet);

        temp.aimPart    = humanoidParts.aimPart;
        temp.rigidRoot  = humanoidParts.rigidRoot;
        humanoidParts   = temp;
        animationHash   = new AnimationHash(animator);
        actorBehaviours = new PlayerBehaviours(this, new FBIKChain[] { fullBodyBipedIK.solver.rightArmChain }, new IKEffector[] { fullBodyBipedIK.solver.rightHandEffector });

        // 事件的绑定:
        MessageManager.AddListener("OnStabIn", OnStabIn, transform);
    }
示例#8
0
    // Start is called before the first frame update
    void Start()
    {
        if (thisBulletType != BulletType.DUD)
        {
            moveSpeed = 15f;
        }

        coll = GetComponent <BoxCollider2D>();
        InvokeRepeating("CollDisableTimer", 0.1f, 0.1f);
        coll.gameObject.SetActive(false);

        bulletDuration = 0;

        playerShip       = GameObject.FindGameObjectWithTag("Player");
        playerShipScript = playerShip.GetComponent <PlayerBehaviours>();
    }
示例#9
0
		private void Awake()
		{
			m_Character = GetComponent<PlayerBehaviours>();
		}
示例#10
0
 // Use this for initialization
 public void InitializePlayerEventController(PlayerBehaviours playerBehaviours)
 {
     this.playerBehaviours = playerBehaviours;
 }
示例#11
0
 public PlayerBodyBehaviours(PlayerBehaviours abb) : base(abb)
 {
     hp = abb.ac.humanoidParts;
 }
示例#12
0
    void FixedUpdate()
    {
        if (_prevSelectedBehaviour != selectedBehaviour || _behaviour == null)
        {
            if (_behaviour != null)
            {
                Destroy(_behaviour);
            }

            System.Type type;
            switch (selectedBehaviour)
            {
            default:
                type = typeof(JumpingPlayerBehaviour);
                break;
            }

            _behaviour = gameObject.AddComponent(type) as AbstractPlayerBehaviour;
        }

        if (_doDoubleJump)
        {
            _doDoubleJump           = false;
            _behaviour.doDoubleJump = true;
        }

        switch (state)
        {
        case PlayerState.Idle:
            //Do Nothing
            break;

        case PlayerState.Dead:
            if (_prevState != state)
            {
                transform.Rotate(Vector3.forward, 180);
            }
            break;

        case PlayerState.Grounded:
            if (isImmortal)
            {
                isImmortal = false;
            }

            // StopCoroutine(JumpAnimation());
            //StartCoroutine(JumpAnimation());
            _groundedWait = false;

            _canDoubleJump = true;
            _behaviour.GroundedBehaviour();
            break;

        case PlayerState.InAir:

            if (_prevState != state)
            {
                _animator.SetFloat(ANIM_FORCE, 0.5f);
            }


            if (mRigidbody.velocity.y <= 0)
            {
                state = PlayerState.Falling;
            }

            _behaviour.InAirBehaviour();

            if (!_animationSet && mRigidbody.velocity.y <= 0.5f)
            {
                _animationSet = true;
                _animator.SetFloat(ANIM_FORCE, 1);
            }

            break;

        case PlayerState.Falling:
            _animationSet = false;
            _behaviour.FallingBehaivour();
            if (!_groundedWait && CheckGroundCollision())
            {
                _groundedWait = true;
                _animator.SetFloat(ANIM_FORCE, 0);
                StopCoroutine(GroundedWait());
                StartCoroutine(GroundedWait());
            }
            break;
        }

        if (transform.position.x < _areaMinX)
        {
            transform.position = new Vector3(_areaMaxX, transform.position.y);
        }

        if (transform.position.x > _areaMaxX)
        {
            transform.position = new Vector3(_areaMinX, transform.position.y);
        }

        _prevState             = state;
        _prevSelectedBehaviour = selectedBehaviour;

        if (direction != _prevDirection)
        {
            Vector3 newScale = transform.localScale;
            newScale.x           = _defaultScaleX * direction;
            transform.localScale = newScale;
        }

        _prevDirection = direction;
    }