Inheritance: MonoBehaviour
    void Awake()
    {
        if (blackWolf)
        {
            target = GameObject.FindWithTag("Player").transform;
        }

        if (Harpy)
        {
            GameObject player = GameObject.FindWithTag("Player");        //create reference for Player gameobject, and assign the variable via FindWithTag at start
            if (player != null)                                          // if the playerObject gameObject-reference is not null - assigning the reference via FindWithTag at first frame -
            {
                playerScript = player.GetComponent <PlayerController>(); // - set the PlayerController-reference (called playerControllerScript) to the <script component> of the Player gameobject (via the gameObject-reference) to have access the instance of the PlayerController script
            }
            if (player == null)                                          //for exception handling - to have the console debug the absense of a player controller script in order for this entire code, the code in the GameController to work
            {
                Debug.Log("Cannot find ScoreController script for final score referencing to GameOver - finalAcquired Label");
            }
        }

        GameObject player2 = GameObject.FindWithTag("Player"); //create reference for Player gameobject, and assign the variable via FindWithTag at start

        if (player2 != null)                                   // if the playerObject gameObject-reference is not null - assigning the reference via FindWithTag at first frame -
        {
            playerScript2 = player2.GetComponent <PlayerCollider>();
        }
        if (player2 == null) //for exception handling - to have the console debug the absense of a player controller script in order for this entire code, the code in the GameController to work
        {
            Debug.Log("Cannot find ScoreController script for final score referencing to GameOver - finalAcquired Label");
        }
    }
示例#2
0
    private void Update()
    {
        if (!m_matorCharacter)
        {
            return;
        }

        m_matorCharacter.SetFloat
        (
            "Speed",
            C_SimpleMath.GetSpeed(ref m_fControllerHorizontal, ref m_fControllerVertical)
        );

        if (PlayerCollider.GetInstance() && PlayerCollider.GetInstance().IsFalling())
        {
            transform.position += new Vector3(0.0f, -m_fFallingSpeed, 0.0f);

            return;
        }

        if (m_fControllerHorizontal != 0.0f && m_fControllerVertical != 0.0f)
        {
            Vector3 vecLook = new Vector3(m_fControllerHorizontal, 0.0f, m_fControllerVertical);

            transform.rotation = Quaternion.LookRotation(vecLook);
        }
    }
示例#3
0
 public override void UpdateAfterCollisionCheck(PlayerCollider collider, PlayerStatus status, PlayerInput input)
 {
     if (collider.collisions.above == true)
     {
         status.SetState(PlayerStatus.fall);
     }
 }
示例#4
0
    /**
     * <summary>
     *  Will be called at the start of the game.
     *  Sets the masks of the colliders.
     * </summary>
     */
    public virtual void Init(CapsuleCollider2D playerCollider, PlayerCollider wallLeft, PlayerCollider wallRight, PlayerCollider ground, LayerMask groundMask)
    {
        this.playerCollider         = playerCollider;
        this.onGroundCollider       = ground;
        this.wallSlideColliderLeft  = wallLeft;
        this.wallSlideColliderRight = wallRight;

        this.onGroundCollider.mask       = groundMask;
        this.wallSlideColliderLeft.mask  = groundMask;
        this.wallSlideColliderRight.mask = groundMask;

        this.movementInput     = 0;
        this.duckInput         = false;
        this.lookUpInput       = false;
        this.cancelInput       = false;
        this.castInput         = false;
        this.jumpInput         = false;
        this.aimDirecton       = Vector2.right;
        this.waterElementInput = false;
        this.fireElementInput  = false;
        this.airElementInput   = false;
        this.earthElementInput = false;
        this.settingsInput     = false;

        this.pauseScene = this.GetComponent <SceneLoader>();
    }
    void Awake()
    {
        if(blackWolf)
        {
            target = GameObject.FindWithTag("Player").transform;
        }

        if(Harpy)
        {
            GameObject player = GameObject.FindWithTag("Player"); //create reference for Player gameobject, and assign the variable via FindWithTag at start
            if (player != null) // if the playerObject gameObject-reference is not null - assigning the reference via FindWithTag at first frame -
            {
                playerScript = player.GetComponent<PlayerController>();// - set the PlayerController-reference (called playerControllerScript) to the <script component> of the Player gameobject (via the gameObject-reference) to have access the instance of the PlayerController script
            }
            if (player == null) //for exception handling - to have the console debug the absense of a player controller script in order for this entire code, the code in the GameController to work
            {
                Debug.Log("Cannot find ScoreController script for final score referencing to GameOver - finalAcquired Label");
            }
        }

        GameObject player2 = GameObject.FindWithTag("Player"); //create reference for Player gameobject, and assign the variable via FindWithTag at start
        if (player2 != null) // if the playerObject gameObject-reference is not null - assigning the reference via FindWithTag at first frame -
        {
            playerScript2 = player2.GetComponent<PlayerCollider>();
        }
        if (player2 == null) //for exception handling - to have the console debug the absense of a player controller script in order for this entire code, the code in the GameController to work
        {
            Debug.Log("Cannot find ScoreController script for final score referencing to GameOver - finalAcquired Label");
        }
    }
        public RustySpike(Vector2 position, int size, Directions direction)
            : base(position, size, direction)
        {
            switch (direction)
            {
            case Directions.Up:
                base.Collider = new Hitbox(size, 3f, 0f, -3f);
                Add(new LedgeBlocker());
                break;

            case Directions.Down:
                base.Collider = new Hitbox(size, 3f);
                break;

            case Directions.Left:
                base.Collider = new Hitbox(3f, size, -3f);
                Add(new LedgeBlocker());
                break;

            case Directions.Right:
                base.Collider = new Hitbox(3f, size);
                Add(new LedgeBlocker());
                break;
            }
            Add(pc = new PlayerCollider(OnCollide));
        }
示例#7
0
        public PlayerComponent(
            IGamepad gamepad,
            PlayerRigidbody playerRigidbody,
            PlayerSoundsComponent playerSounds,
            PlayerStateMachine playerStateMachine)
        {
            this.gamepad_ = gamepad;

            this.playerRigidbody_ = playerRigidbody;
            this.rigidbody_       = playerRigidbody.Rigidbody;

            this.playerSounds_ = playerSounds;
            this.stateMachine_ = playerStateMachine;

            this.levelGridRenderer_ = new LevelGridRenderer {
                LevelGrid = LevelConstants.LEVEL_GRID,
            };

            this.motor_ = new PlayerMotor {
                StateMachine    = this.stateMachine_,
                PlayerRigidbody = this.playerRigidbody_,
            };

            this.collider_ = new PlayerCollider {
                StateMachine    = this.stateMachine_,
                PlayerRigidbody = this.playerRigidbody_,
            };

            this.boxPlayerRenderer_ = new BoxPlayerRenderer {
                PlayerRigidbody = this.playerRigidbody_,
            };
        }
示例#8
0
    public Player(int id, PlayerData playerData)
    {
        if (playerData == null)
        {
            return;
        }
        m_playerData = playerData;
        m_id         = id;

        GameResModuel resModuel = GameStart.GetInstance().ResModuel;
        GameObject    player    = resModuel.LoadResources <GameObject>(EResourceType.Role, playerData.m_playerResPath);

        player = CommonFunc.Instantiate(player);
        if (player != null)
        {
            player.name = playerData.m_playerName;
            m_avatar    = player.AddComponent <PlayerAvatar>();

            m_anim = new PlayerAnim(player);
            m_anim.InitAnimator(playerData.m_animControllerName);

            GameObject collider = CommonFunc.GetChild(player, "Collider");
            m_collider = new PlayerCollider(playerData.m_moveArea, playerData.m_radius, playerData.m_angle, collider.GetComponent <BoxCollider2D>());

            MovePosition(m_playerData.m_bornPosition);
        }
    }
示例#9
0
    public override void UpdateState(Transform ball)
    {
        if (ball == null)
        {
            return;
        }
        Vector3 position = ball.position;

        if (position.y < m_player.GetPlayerPosition().y)
        {
            Vector3 moveDir = position - m_player.GetPlayerPosition();
            moveDir = moveDir.normalized;

            position  = m_player.GetPlayerPosition();
            position += Time.deltaTime * moveDir * m_player.PlayerData.m_moveSpeed;
            m_player.MovePosition(position);

            bool checkInArea = PlayerCollider.CheckInHitBallArea(ball, m_player.Transform,
                                                                 m_player.PlayerData.m_radius, m_player.PlayerData.m_angle, m_player.BoxCollider);
            if (checkInArea && SwitchStateAction != null)
            {
                SwitchStateAction(EAIControlState.Hit);
            }
        }
        else
        {
            if (SwitchStateAction != null)
            {
                SwitchStateAction(EAIControlState.BackToBornPoint);
            }
        }
    }
示例#10
0
    // Update is called once per frame
    void Update()
    {
        PlayerCollider other = player.GetComponent <PlayerCollider> ();

        life = other.getLife();

        if (life == 0)
        {
            if (currentTime == 0f)
            {
                currentTime = delay;

                float vol = Random.Range(volLowRange, volHighRange);
                source.PlayOneShot(playerDead, vol);
                currentTime = 2f;
            }
            else
            {
                currentTime = 2f;
            }
            isAlive = false;
            gameover.gameObject.SetActive(true);
            //Destroy (player.GetComponent<Animator>());
        }
        else
        {
            health.fillAmount = ((int)(life / 4) * 0.25f);
        }
    }
示例#11
0
 // Use this for initialization
 void Start()
 {
     playerCollider = FindObjectOfType <PlayerCollider>();
     if (playerCollider == null)
     {
         Debug.LogError("playerCollider not found.");
     }
 }
示例#12
0
 public void Initialize()
 {
     position   = new Position();
     collider   = new PlayerCollider();
     PlayerSize = 7;
     position.SetPosition(38, 21);
     GameMap.GetInstance.SetObjectInMap("Player", PlayerSize, position);
 }
示例#13
0
 // Use this for initialization
 void Start()
 {
     rigid      = gameObject.GetComponent <Rigidbody>();
     playerCol  = GetComponentInChildren <PlayerCollider>();
     sliderCtrl = GameObject.FindGameObjectWithTag("GameCtrl").GetComponent <SliderController>();
     jumpSE     = GameObject.FindGameObjectWithTag("GameCtrl").GetComponent <AudioSource>();
     roboAni    = GetComponent <Animator>();
 }
示例#14
0
 private void Start()
 {
     m_Rigidbody        = GetComponent <Rigidbody2D>();
     transform.position = new Vector3(m_InitialHolder.position.x, 0, 0);
     m_HolderPoints     = GetComponent <HolderPoints>();
     m_Collider         = GetComponent <PlayerCollider>();
     m_LifeState        = ELifeStates.LIVE;
 }
示例#15
0
 public override void UpdateAfterCollisionCheck(PlayerCollider collider, PlayerStatus status, PlayerInput input)
 {
     if (collider.IsGrounded() == false)
     {
         status.SetState(PlayerStatus.fall);
         status.framesInDelayCount = 0;
     }
 }
示例#16
0
 public override void UpdateAfterCollisionCheck(PlayerCollider collider, PlayerStatus status, PlayerInput input)
 {
     if (collider.collisions.below == true)
     {
         status.SetState(PlayerStatus.idle);
         //         status.SetInitialModelRotation();
     }
 }
 // Use this for initialization
 void Start()
 {
     GameObject playerColliderObject = GameObject.FindWithTag("Player"); //to call another method from another script, reference is required
     if (playerColliderObject != null)
     {
         playerCollider = playerColliderObject.GetComponent<PlayerCollider>();
     }
 }
 void Start()
 {
     GameObject playerColliderObject = GameObject.FindWithTag("Player"); // allows us to pull Life Check Method from the player collider script
     if (playerColliderObject != null)
     {
         playerCollider = playerColliderObject.GetComponent<PlayerCollider>();
     }
 }
示例#19
0
        public SpeedBerry(EntityData data, Vector2 offset, EntityID id, bool restored) : base(data, offset, id)
        {
            EntityData = data;
            new DynData <Strawberry>(this)["Golden"] = true;
            BronzeTime                = data.Float("bronzeTime", 15f);
            SilverTime                = data.Float("silverTime", 10f);
            GoldTime                  = data.Float("goldTime", 5f);
            this.restored             = restored;
            Follower.PersistentFollow = true;
            var listener = new TransitionListener()
            {
                OnOutBegin = () => {
                    SceneAs <Level>()?.Session.DoNotLoad.Add(ID);
                    transitionStart  = Position;
                    transitionTarget = new Vector2(
                        Calc.Clamp(transitionStart.X, SceneAs <Level>().Bounds.Left + 8f, SceneAs <Level>().Bounds.Right - 8f),
                        Calc.Clamp(transitionStart.Y, SceneAs <Level>().Bounds.Top + 8f, SceneAs <Level>().Bounds.Bottom - 8f));
                },
                OnOut = percent => {
                    if (SceneAs <Level>()?.Tracker.GetEntity <Player>()?.CollideCheck <SpeedBerryCollectTrigger>() ?? false)
                    {
                        // as soon as the transition is over, the berry will be collected, so be sure to drag it on the new screen
                        // so that the player actually sees it collect.
                        Position = Vector2.Lerp(transitionStart, transitionTarget, Ease.SineOut(percent));
                        forcePositionToTransitionTarget = true;
                    }
                }
            };

            Add(listener);

            if (P_SilverGlow == null)
            {
                P_SilverGlow = new ParticleType(P_Glow)
                {
                    Color  = Calc.HexToColor("B3AF9F"),
                    Color2 = Calc.HexToColor("E6DCB5")
                };
                P_BronzeGlow = new ParticleType(P_Glow)
                {
                    Color  = Calc.HexToColor("9A5B3C"),
                    Color2 = Calc.HexToColor("ECAF66")
                };
                P_OrigGoldGlow = P_GoldGlow;
            }

            // the speed berry most certainly shouldn't flip the "grabbed golden" switch in session.
            PlayerCollider  collider = Get <PlayerCollider>();
            Action <Player> onPlayer = collider.OnCollide;

            collider.OnCollide = player => {
                bool bakGrabbedGolden = (Scene as Level).Session.GrabbedGolden;
                onPlayer(player);
                (Scene as Level).Session.GrabbedGolden = bakGrabbedGolden;
            };
        }
示例#20
0
    private void HitBallDelegate(Player player, Vector2 direction, float force, int id)
    {
        if (m_gameBall == null)
        {
            return;
        }

        bool checkIsHitArea = PlayerCollider.CheckInHitBallArea(m_gameBall.GetBallInstance().transform, player.Transform,
                                                                player.PlayerData.m_radius, player.PlayerData.m_angle, player.BoxCollider);

        if (checkIsHitArea)
        {
            CameraControl.GetInstance().Trigger();
            CameraControl.GetInstance().TriggerMask();

            GameAudioModuel audioModuel = GameStart.GetInstance().AudioModuel;
            if (id == m_player.ID)
            {
                GameEventModuel meoduel = GameStart.GetInstance().EventModuel;
                meoduel.SendEvent(GameEventID.PLAYER_HIT_BALL, true, 0f);

                m_side = ESide.Player;
                m_contestData.AddIndex();

                m_contestUI.FreshUI(m_contestData.m_heart, m_contestData.m_index);
                if (m_contestData != null && m_contestData.m_changeAudio && !m_change)
                {
                    List <string> list = new List <string>
                    {
                        "lerp",
                        "BGM_002",
                    };
                    audioModuel.PlayBgAudio(list);
                    m_change = true;
                }

                m_playerIndex++;
                m_playerIndex = Mathf.Clamp(m_playerIndex, 0, m_audioNameList.Count - 1);
                audioModuel.PlayAudio(m_audioNameList[m_playerIndex]);
            }
            else
            {
                m_side = ESide.AI;
                m_aiIndex++;
                m_aiIndex = Mathf.Clamp(m_aiIndex, 0, m_audioNameList.Count - 1);
                audioModuel.PlayAudio(m_audioNameList[m_aiIndex]);
            }

            if (m_gameBall != null)
            {
                ESide side = (id == m_player.ID) ? ESide.Player : ESide.AI;
                m_gameBall.SetVelocity(direction, force, side);
                m_gameBall.ChangeEffectDir(side);
            }
        }
    }
示例#21
0
 public RechargePlatform(Vector2 Position) : base(Position, 24, 4, true)
 {
     Add(sprite            = BatteriesModule.SpriteBank.Create("recharge_platform"));
     Collider.BottomCenter = Vector2.Zero;
     Add(playerCollider    = new PlayerCollider(OnPlayerCollide, nc = Collider.Clone()));
     nc.Width   += 2;
     nc.Height  += 3;
     nc.CenterX -= 1;
     nc.CenterY -= 3;
 }
示例#22
0
        public AngryOshiroRight(Vector2 position, bool fromCutscene = false) : base(position)
        {
            Add(Sprite = GFX.SpriteBank.Create("oshiro_boss"));
            Sprite.Play("idle");
            Add(lightning      = GFX.SpriteBank.Create("oshiro_boss_lightning"));
            lightning.Visible  = false;
            lightning.OnFinish = s => lightningVisible = false;
            Collider           = new Circle(14f);
            Collider.Position  = colliderTargetPosition = new Vector2(-3f, 4f);
            Add(sine           = new SineWave(0.5f));
            Add(bounceCollider = new PlayerCollider(OnPlayerBounce, new Hitbox(28f, 6f, -17f, -11f)));
            Add(new PlayerCollider(OnPlayer));
            Depth      = -12500;
            Visible    = false;
            Add(light  = new VertexLight(Color.White, 1f, 32, 64));
            Add(shaker = new Shaker(false));
            state      = new StateMachine();
            state.SetCallbacks(StChase, ChaseUpdate, ChaseCoroutine, ChaseBegin);
            state.SetCallbacks(StChargeUp, ChargeUpUpdate, ChargeUpCoroutine, null, ChargeUpEnd);
            state.SetCallbacks(StAttack, AttackUpdate, AttackCoroutine, AttackBegin, AttackEnd);
            state.SetCallbacks(StDummy, null);
            state.SetCallbacks(StWaiting, WaitingUpdate);
            state.SetCallbacks(StHurt, HurtUpdate, null, HurtBegin);
            Add(state);
            if (fromCutscene)
            {
                yApproachSpeed = 0f;
            }
            this.fromCutscene = fromCutscene;
            Add(new TransitionListener {
                OnOutBegin = () => {
                    if (X < level.Bounds.Right - Sprite.Width / 2.0)
                    {
                        Visible = false;
                    }
                    else
                    {
                        easeBackFromRightEdge = true;
                    }
                },
                OnOut = f => {
                    lightning.Update();
                    if (!easeBackFromRightEdge)
                    {
                        return;
                    }

                    X += 128f * Engine.RawDeltaTime;
                }
            });
            Add(prechargeSfx      = new SoundSource());
            Add(chargeSfx         = new SoundSource());
            Distort.AnxietyOrigin = new Vector2(1f, 0.5f);
            Sprite.Scale.X       *= -1;
        }
示例#23
0
    public void Destroy()
    {
        if (m_avatar != null)
        {
            GameObject.Destroy(m_avatar.gameObject);
        }


        m_anim            = null;
        m_collider        = null;
        m_hitBallCallBack = null;
    }
示例#24
0
    void Start()
    {
        PhoneInput phoneInput = this.GetComponent <PhoneInput>();

        phoneInput.onJumpCallback   = this.onJumpCallback;
        phoneInput.onCrouchCallback = this.onCrouchCallback;

        PlayerCollider playerCollider = this.GetComponent <PlayerCollider>();

        playerCollider.onCollideCallback = this.onCollideCallback;

        this.originalPosition = this.transform.position;
    }
示例#25
0
    public void CollisionDetected(PlayerCollider childScript)
    {
        if (started)
        {
            GameManager.instance.soundManager.PlayClipWithPitch(GameManager.instance.soundManager.deathSound, 0.1f, 0.8f);

            enabled = false;

            frontSRend.color = Color.black;
            backSRend.color  = Color.black;
            GameManager.instance.PlayerLoss();
        }
    }
 void Start()
 {
     map = player.GetComponentInChildren<MiniMap> ();
     pc = player.GetComponent<PlayerCollider> ();
     switch (mapId) {
     case 1:
         map.InitializeMap (MapDatas.map1);
         break;
     case 2:
         map.InitializeMap (MapDatas.map2);
         break;
     }
 }
示例#27
0
    public override void UpdateAfterCollisionCheck(PlayerCollider collider, PlayerStatus status, PlayerInput input)
    {
        if (collider.IsGrounded() == false)
        {
            status.SetState(PlayerStatus.fall);
            status.framesInDelayCount = 0;
        }

        if ((collider.collisions.left == true && input.newInput.GetHorizontalInput() < 0) || (collider.collisions.right == true && input.newInput.GetHorizontalInput() > 0))
        {
            status.SetState(PlayerStatus.idle);
        }
    }
示例#28
0
        public MultiplayerTriggerSpikes(Vector2 position, int size, Directions direction)
            : base(position)
        {
            this.size      = size;
            this.direction = direction;
            switch (direction)
            {
            case Directions.Up:
                tentacleTextures = GFX.Game.GetAtlasSubtextures("danger/triggertentacle/wiggle_v");
                outwards         = new Vector2(0f, -1f);
                offset           = new Vector2(0f, -1f);
                base.Collider    = new Hitbox((float)size, 4f, 0f, -4f);
                base.Add(new SafeGroundBlocker(null));
                base.Add(new LedgeBlocker(UpSafeBlockCheck));
                break;

            case Directions.Down:
                tentacleTextures = GFX.Game.GetAtlasSubtextures("danger/triggertentacle/wiggle_v");
                outwards         = new Vector2(0f, 1f);
                base.Collider    = new Hitbox((float)size, 4f, 0f, 0f);
                break;

            case Directions.Left:
                tentacleTextures = GFX.Game.GetAtlasSubtextures("danger/triggertentacle/wiggle_h");
                outwards         = new Vector2(-1f, 0f);
                base.Collider    = new Hitbox(4f, (float)size, -4f, 0f);
                base.Add(new SafeGroundBlocker(null));
                base.Add(new LedgeBlocker(SideSafeBlockCheck));
                break;

            case Directions.Right:
                tentacleTextures = GFX.Game.GetAtlasSubtextures("danger/triggertentacle/wiggle_h");
                outwards         = new Vector2(1f, 0f);
                offset           = new Vector2(1f, 0f);
                base.Collider    = new Hitbox(4f, (float)size, 0f, 0f);
                base.Add(new SafeGroundBlocker(null));
                base.Add(new LedgeBlocker(SideSafeBlockCheck));
                break;
            }
            base.Add(pc = new PlayerCollider(OnCollide, null, null));
            base.Add(new StaticMover
            {
                OnShake         = new Action <Vector2>(OnShake),
                SolidChecker    = new Func <Solid, bool>(IsRiding),
                JumpThruChecker = new Func <JumpThru, bool>(IsRiding)
            });
            base.Add(new DustEdge(RenderSpikes));
            base.Depth = -50;
        }
示例#29
0
        public TriggerSpikesOriginal(Vector2 position, int size, Directions direction, string overrideType, float delayTime)
            : base(position)
        {
            this.size         = size;
            this.direction    = direction;
            this.overrideType = overrideType;
            this.delayTime    = delayTime;

            switch (direction)
            {
            case Directions.Up:
                outwards = new Vector2(0f, -1f);
                Collider = new Hitbox(size, 3f, 0f, -3f);
                Add(new SafeGroundBlocker());
                Add(new LedgeBlocker(UpSafeBlockCheck));
                break;

            case Directions.Down:
                outwards = new Vector2(0f, 1f);
                Collider = new Hitbox(size, 3f, 0f, 0f);
                break;

            case Directions.Left:
                outwards = new Vector2(-1f, 0f);
                Collider = new Hitbox(3f, size, -3f, 0f);

                Add(new SafeGroundBlocker());
                Add(new LedgeBlocker(SideSafeBlockCheck));
                break;

            case Directions.Right:
                outwards = new Vector2(1f, 0f);
                Collider = new Hitbox(3f, size, 0f, 0f);

                Add(new SafeGroundBlocker());
                Add(new LedgeBlocker(SideSafeBlockCheck));
                break;
            }

            Add(pc = new PlayerCollider(OnCollide));

            Add(new StaticMover {
                OnShake         = OnShake,
                SolidChecker    = IsRiding,
                JumpThruChecker = IsRiding
            });

            Depth = -50;
        }
示例#30
0
    //public InputTest;
    void Start()
    {
        i     = 0;
        queue = new Queue <string>();
        dialogueOptions.SetActive(false);
        playerColl = player.GetComponent <PlayerCollider>();
        controls   = playerColl.controls;
        controls.Gameplay.Next.performed += ctx => InteractDiag();

        /*foreach(Transform child in dialogueOptions.transform.GetChild(i))
         * {
         *  responsesList[i] = child.GetComponent<Button>();
         *  i++;
         * }*/
    }
示例#31
0
 void Start()
 {
     if (useInputAI)
     {
         playerInput = GetComponent <PlayerInputAI>();
     }
     else
     {
         playerInput = GetComponent <PlayerInput> ();
     }
     playerStatus   = GetComponent <PlayerStatus> ();
     playerMove     = GetComponent <PlayerMove> ();
     playerCollider = GetComponent <PlayerCollider> ();
     playerAnimator = GetComponent <Animator> ();
 }
示例#32
0
    /// <summary>
    /// When enemy is touching player, then lower player's health bar until it reaches zero.
    /// </summary>
    public void Attack()
    {
        if (PlayerData.instance.GetComponent <Animator>().GetBool("isDead"))
        {
            return;
        }

        if (!Attacked)
        {
            transform.position = new Vector2(transform.position.x, transform.position.y - 1f);
            GetComponent <Rigidbody2D>().velocity = Vector2.zero;
            PlayerCollider.GetComponent <PlayerData>().TakeDamage((short)AttackDamage);
            Attacked            = true;
            AttackCoolDownTimer = 0;
        }
    }
示例#33
0
 public bool AllowHorizontalInput(PlayerStatus status, PlayerCollider collider)
 {
     if (status.IsDead())
     {
         return(false);
     }
     if (collider.IsGrounded() == false && status.WasDead() == false)
     {
         return(true);
     }
     if (status.IsIdle() || status.IsWalk())
     {
         return(true);
     }
     return(false);
 }
示例#34
0
 public override void UpdateAfterCollisionCheck(PlayerCollider collider, PlayerStatus status, PlayerInput input)
 {
     if (collider.IsGrounded() && attackFramesCount >= attackFramesDuration)
     {
         if (input.newInput.GetHorizontalInput() != 0)
         {
             status.SetState(PlayerStatus.walk);
         }
         else
         {
             status.SetState(PlayerStatus.idle);
         }
         status.attackCollider.enabled = false;
         status.lightningGenerator.SetActive(false);  // lightning off
         attackFramesCount = 0;
     }
 }
    // Use this for initialization
    void Start()
    {
        //if(playerScript != null)
        //{
            //this.keepScore = playerScript.scoreValue;
        //}

        player = GameObject.FindWithTag("Player"); //create reference for Player gameobject, and assign the variable via FindWithTag at start
        if (player != null) // if the playerObject gameObject-reference is not null - assigning the reference via FindWithTag at first frame -
        {
            playerScript = player.GetComponent<PlayerCollider>();// - set the PlayerController-reference (called playerControllerScript) to the <script component> of the Player gameobject (via the gameObject-reference) to have access the instance of the PlayerController script
        }
        if (player == null) //for exception handling - to have the console debug the absense of a player controller script in order for this entire code, the code in the GameController to work
        {
            Debug.Log("Cannot find ScoreController script for final score referencing to GameOver - finalAcquired Label");
        }
        this.loadLevelIndex = playerScript.loadlevel;
    }
 void Awake()
 {
     manager = this.GetComponent<PlayerCollider> ();
     coinValueAnim = coinValue.GetComponent <Animator> ();
     coinValueText = coinValue.transform.GetChild(0).GetComponent <Text> ();
 }
示例#37
0
    // Use this for initialization
    void Start()
    {
        this._rigidbody2D = gameObject.GetComponent<Rigidbody2D> (); //referencing the rigidbody 2d and transform
        this._transform = gameObject.GetComponent<Transform> ();
        this._animator = gameObject.GetComponent<Animator> ();

        GameObject playerColliderObject = GameObject.FindWithTag("Player"); // allows us to pull Life Check Method from the player collider script
        if (playerColliderObject != null)
        {
            playerCollider = playerColliderObject.GetComponent<PlayerCollider>();
        }
    }