Inheritance: MonoBehaviour
コード例 #1
0
ファイル: SwipeDetector.cs プロジェクト: lutrampal/ProjetDUT
 void Start()
 {
     minSwipeDist = 1;
     controlledPlayer = GetComponent<PlayerWalk>();
     cam = Camera.main;
     old_cam_pos = cam.transform.position;
 }
コード例 #2
0
ファイル: Player.cs プロジェクト: memsyi/marioBadClone
    void Awake()
    {
        if (instance != null && instance != this)
        {
            Destroy(this.gameObject);
        }
        else
        {
            instance = this;
            DontDestroyOnLoad(gameObject);
        }

        PauseGameManager.Instance.register(this, gameObject);

        jump         = GetComponent <Jump>();
        walk         = GetComponent <PlayerWalk>();
        firePivot    = transform.FindChild("FirePivot");
        teleportable = GetComponent <Teleportable>();
        dieAnim      = GetComponent <PlayerDieAnim>();
        crouch       = GetComponent <Crouch>();
        idle         = GetComponent <Idle>();
        lookUpwards  = GetComponent <LookUpwards>();
        body         = GetComponent <ChipmunkBody>();

        walkVelBackup  = walkVelocity;
        rightFireDir.x = 1f;
        rightFireDir.y = -0.5f;
        leftFireDir.x  = -1f;
        leftFireDir.y  = -0.5f;
        fireDir        = rightFireDir;

        collisionGroupSkip = GetComponent <ChipmunkShape>().collisionGroup;
        collisionLayers    = unchecked ((uint)~(1 << gameObject.layer));     // all layers except Player's layer
    }
コード例 #3
0
 private void Awake()
 {
     rigRigidbody = GetComponent <Rigidbody>();
     playerInput  = GetComponent <PlayerInput>();
     playerClimb  = GetComponent <PlayerClimb>();
     playerWalk   = GetComponent <PlayerWalk>();
 }
コード例 #4
0
 private void Awake()
 {
     weapon     = GetComponent <WeaponController>();
     energy     = GetComponent <EnergyController>();
     playerWalk = GetComponent <PlayerWalk>();
     sounds     = GetComponent <Sounds>();
 }
コード例 #5
0
ファイル: PlayerHealth.cs プロジェクト: trobol/sp19-ggj
 void Awake()
 {
     currentHealth  = startingHealth;
     playerMovement = GetComponent <PlayerWalk> ();
     playerShooting = GetComponentInChildren <PlayerShooting>();
     gm             = GameObject.FindGameObjectWithTag("GameController").GetComponent <GameManager>();
 }
コード例 #6
0
    private void Start()
    {
        base.Initial();
        Animator animator;

        animator = GetComponent <Animator>();

        #region 设置角色控制器的大小
        control        = GetComponent <CharacterController>();
        control.center = new Vector3(0, 1, 0);
        control.height = 2;
        control.radius = 0.23f;
        #endregion

        #region 添加动画
        PlayerIdel playerIdel = new PlayerIdel(animator);
        fsmManager.AddState(playerIdel);
        PlayerWalk playerWalk = new PlayerWalk(animator);
        fsmManager.AddState(playerWalk);
        PlayerRun playerRun = new PlayerRun(animator);
        fsmManager.AddState(playerRun);
        PlayerAttack playerAttack = new PlayerAttack(animator);
        fsmManager.AddState(playerAttack);
        PlayerAttacked playerAttacked = new PlayerAttacked(animator, this);
        fsmManager.AddState(playerAttacked);
        PlayerDie playerDie = new PlayerDie(animator);
        fsmManager.AddState(playerDie);
        #endregion
    }
コード例 #7
0
	// Use this for initialization
	void Start () {
		//at the beginning, no click action. 
		//set the target position as the current position
		targetPosition = transform.position;
		//get the PlayerWalk.cs component
		playerWalk = this.GetComponent<PlayerWalk> ();
		attack = this.GetComponent<PlayerAttack> ();
	}
コード例 #8
0
    private void Awake()
    {
        PlayerReferences PlayerRefs = gameObject.GetComponentInParent <PlayerReferences>();

        m_PlayerClimb  = PlayerRefs.playerClimb;
        m_PlayerWalk   = PlayerRefs.playerWalk;
        m_RigRigidbody = PlayerRefs.rigRigidbody;
    }
コード例 #9
0
 void InitializeComponents()
 {
     m_PlayerState      = m_Instance.GetComponent <PlayerState>();
     m_PlayerWalk       = m_Instance.GetComponent <PlayerWalk>();
     m_PlayerAction     = m_Instance.GetComponent <PlayerAction>();
     m_PlayerChargeUI   = m_Instance.GetComponent <PlayerChargeUI>();
     m_CanvasGameObject = m_Instance.GetComponentInChildren <Canvas>().gameObject;
 }
コード例 #10
0
 void Start()
 {
     startTime      = Time.time;
     hitObjectText  = GameObject.Find("Timer").GetComponent(typeof(Text)) as Text;
     timer          = GameObject.Find("Timer").GetComponent(typeof(CountdownTimer)) as CountdownTimer;
     walk           = GameObject.Find("Player").GetComponent(typeof(PlayerWalk)) as PlayerWalk;
     cameraSwitcher = GameObject.Find("floor").GetComponent(typeof(PlayerOrientation)) as PlayerOrientation;
 }
コード例 #11
0
	void Awake(){
		walk = this.GetComponent<PlayerWalk> ();
		ps = this.GetComponent<PlayerStatus> ();
		hudtextFollow = transform.Find ("HUDText").gameObject;

		foreach (GameObject go in efxArray) {
			efxDict.Add(go.name,go);
		}
	}
コード例 #12
0
 // Use this for initialization
 void Awake()
 {
     lookUpAC = AnimateTiledConfig.getByName(gameObject, EnumAnimateTiledName.LookUpwards, true);
     dirSign  = 0f;
     walk     = GetComponent <PlayerWalk>();
     // since we cannot create an instance from a MonoBehaviour then do next
     tempConfig = gameObject.AddComponent <PlayerFollowerXYConfig>();
     // disable the dummy component from being updated by Unity3D game loop
     tempConfig.enabled = false;
 }
コード例 #13
0
    private void Awake()
    {
        walkController = player.GetComponent <PlayerWalk>();
        dashController = player.GetComponent <PlayerDash>();
        jumpController = player.GetComponent <PlayerJump>();
        fireController = player.GetComponent <PlayerFire>();

        thisTransform = gameObject.GetComponent <Transform>();

        energy     = player.GetComponent <EnergyController>();
        playerBody = player.GetComponent <Rigidbody2D>();
        sprite     = GetComponent <SpriteRenderer>();
        sounds     = GetComponent <Sounds>();
    }
コード例 #14
0
ファイル: ChanPlayerCtrl.cs プロジェクト: Nonomen/Function
    // Use this for initialization
    void Start()
    {
        fsmManager = new FSMManager((int)AnimationEnum.Max);
        Animator   animator = GetComponent <Animator>();
        PlayerWait tmpWait  = new PlayerWait(animator);

        fsmManager.AddState(tmpWait);
        PlayerJump tmpJump = new PlayerJump(animator, this);

        fsmManager.AddState(tmpJump);
        PlayerWalk tmpWalk = new PlayerWalk(animator);

        fsmManager.AddState(tmpWalk);
        PlayerWait02 tmpWait02 = new PlayerWait02(animator);

        fsmManager.AddState(tmpWait02);
    }
コード例 #15
0
ファイル: NPCPlayer.cs プロジェクト: Parzival42/Bread
    /// <summary>
    /// Setup the state machine.
    /// </summary>
    protected override void MakeFSM()
    {
        base.MakeFSM();

        PlayerWalk walk = new PlayerWalk(StateID.Walk, this);
        walk.AddTransition(Transition.DestinationReached, StateID.Idle);
        walk.AddTransition(Transition.FoundPlayer, StateID.Finished);

        PlayerIdle idle = new PlayerIdle(StateID.Idle, this);
        idle.AddTransition(Transition.WalkToDestination, StateID.Walk);
        idle.AddTransition(Transition.FoundPlayer, StateID.Finished);

        PlayerFinished finished = new PlayerFinished(StateID.Finished, this.gameObject);

        fsm.AddState(walk);
        fsm.AddState(idle);
        fsm.AddState(finished);
    }
コード例 #16
0
    private void initialize()
    {
        jump           = GetComponent <Jump>();
        walk           = GetComponent <PlayerWalk>();
        firePivot      = transform.FindChild("FirePivot");
        teleportable   = GetComponent <Teleportable>();
        dieAnim        = GetComponent <PlayerDieAnim>();
        crouch         = GetComponent <Crouch>();
        idle           = GetComponent <Idle>();
        lookDirections = GetComponent <LookDirections>();
        body           = GetComponent <ChipmunkBody>();

        rightFireDir.x = 1f;
        rightFireDir.y = -0.5f;
        leftFireDir.x  = -1f;
        leftFireDir.y  = -0.5f;
        fireDir        = rightFireDir;

        collisionGroupSkip = GetComponent <ChipmunkShape>().collisionGroup;
        // not sure if ok: all layers except Player's layer
        collisionLayersSkip = unchecked ((uint)(1 << KLayers.PLAYER));
        //collisionLayers = 0;
    }
コード例 #17
0
 // Use this for initialization
 void Start()
 {
     playerWalk = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerWalk>();
 }
コード例 #18
0
ファイル: Slide.cs プロジェクト: JeanTL190/SaveTheAnimals
 private void Start()
 {
     pw        = GetComponent <PlayerWalk>();
     normalMax = pw.GetVelMax();
 }
コード例 #19
0
	// Use this for initialization
	void Start () {
		//get the component PlayerWalk.cs
		walk = this.GetComponent<PlayerWalk>();
		attack = this.GetComponent<PlayerAttack> ();
	}
コード例 #20
0
ファイル: Glisse.cs プロジェクト: lutrampal/ProjetDUT
    /// <summary>
    /// Is called every time an object is colliding.
    /// Help to keep in check the surrounding environment of the block.
    /// </summary>
    /// <param name="collision"></param>
    public void OnCollisionEnter2D(Collision2D collision)
    {
        if (collision.gameObject.tag == "Player" ) { // Check if the colliding object is the player
            player = collision.gameObject.GetComponent("PlayerWalk") as PlayerWalk ; // Get the player Object
            direction = player.getLastInput(); // Allow us to know in which direction the player wanted to go

            // For each direction we check:
            //      -if the player was going in this direction
            //      -if the block has an "solid" object next to him in this direction
            // if the two conditions are true then it call fonctBlocDestruction() because the block is blocked
            // else if neitheir is true it send the block in the direction the player wanted to
            if (direction == "right" && right ){
                fonctBlocDestruction();
            }
            else if (direction == "left" && left){
                fonctBlocDestruction();
            }
            else if (direction == "up" && up){
                fonctBlocDestruction();
            }
            else if (direction == "down" && down){
                fonctBlocDestruction();
            }
            else{
                moving = true;
            }
        }
        else if (collision.gameObject.tag == "Enemy" ){ // Check if the colliding object is an ennemy
            if (moving == true){ // If the block is moving it destroys the ennemy else it doesn't do anything
                fonctCollisionDestruction(collision);
            }
        }
        else	{ // If it isn't the player or an ennemy ist check if our block is moving, if it's moving it check if it's colliding with a "solid" object
                  // If it is, the block stop itself Else it continue sliding
            fonctCollisionEnter(collision);
            if (moving == true)
            {
                if ((collisionposition.x > position.x) && (collisionposition.y == position.y) && (direction == "right"))
                {
                    direction = null;
                    moving = false;
                    target.x = Mathf.Round(transform.position.x);
                }
                if ((collisionposition.x < position.x) && (collisionposition.y == position.y) && (direction == "left"))
                {
                    direction = null;
                    moving = false;
                    target.x = Mathf.Round(transform.position.x);
                }
                if ((collisionposition.y > position.y) && (collisionposition.x == position.x) && (direction == "up"))
                {
                     direction = null;
                     moving = false;
                     target.y = Mathf.Round(transform.position.y);
                }
                if ((collisionposition.y < position.y) && (collisionposition.x == position.x) && (direction == "down"))
                {
                     direction = null;
                     moving = false;
                     target.y = Mathf.Round(transform.position.y);

                }
            }
        }
    }
コード例 #21
0
 private void Awake()
 {
     pw = GetComponent <PlayerWalk>();
 }
コード例 #22
0
ファイル: PlayerJump.cs プロジェクト: Unimoti/anima_life
    private void Start()
    {
        playerWalk = GetComponent <PlayerWalk> ();

        rb = GetComponent <Rigidbody2D> ();
    }
コード例 #23
0
 /// <summary>
 /// Plays a single playerwalk sound effect.
 /// </summary>
 public static void NewPlayerWalk()
 {
     PlayerWalk.Play();
 }
コード例 #24
0
	private PlayerWalk playerCtrl;		// Reference to the PlayerControl script.


	void Awake()
	{
		// Setting up the references.
		animator = transform.root.gameObject.GetComponent<Animator>();
		playerCtrl = transform.root.GetComponent<PlayerWalk>();
	}
コード例 #25
0
 void Start()
 {
     pw = GetComponent <PlayerWalk>();
     rb = GetComponent <Rigidbody2D>();
     scriptGroundCheck = objectGroundCheck.GetComponent <GroundCheck>();
 }
コード例 #26
0
 void Start()
 {
     walkScript     = GetComponent <PlayerWalk>();
     pawnController = GetComponentInChildren <PlayerPawnController>();
 }
コード例 #27
0
 void Start()
 {
     playerWalk = GetComponent <PlayerWalk>();
 }