Inheritance: MonoBehaviour
Example #1
0
	void OnTriggerEnter2D(Collider2D coll){
		if (coll.gameObject.tag == "Player") {
			Debug.Log ("Bepis");
			PlayerControls playerControls = coll.gameObject.GetComponent<PlayerControls> ();
			if (occupied) {
				PlayerControls.EndEdge (occupant, this.gameObject.GetComponent<EdgeGrab>());
			}

			if (coll.gameObject.transform.position.y < stageHeight + .5 && coll.gameObject.transform.position.y > stageHeight - 1 && !playerControls.wasGrabbing && !occupied) {
				playerControls.attachedEdge = this.gameObject;
				playerControls.edgeGrabbing = true;
				occupant = coll.gameObject.GetComponent<PlayerControls> ();
				playerControls.PlayerControl = false;
				if (edge == EdgeSide.Right) {
					playerControls.facingNum = -1;
				} else if (edge == EdgeSide.Left) {
					playerControls.facingNum = 1;
				}
				playerControls.anim.SetBool ("edgeGrabbing", true);
				occupied = true;
				playerControls.timesJumped = 0;
				Debug.Log ("Edge");

			}
		}
	}
 private void HitPlayer(PlayerControls player)
 {
     if (player.Hit(this.transform.position) && roundScript != null)
     {
         roundScript.upScore = true;
     }
 }
        public HelpScreen(Game game, Texture2D background, Rectangle backgroundRect, SpriteFont fontMoves, SpriteFont fontPlayers,  PlayerControls firstPlayer, PlayerControls secondPlayer) : base(game)
        {
            this.background = background;
            this.backgroundRect = backgroundRect;
            this.fontMoves = fontMoves;
            this.fontPlayers = fontPlayers;
            first = new String[9];
            first[0] = movesName[0] + firstPlayer.MoveLeft;
            first[1] = movesName[1] + firstPlayer.MoveRight;
            first[2] = movesName[2] + firstPlayer.MoveUp;
            first[3] = movesName[3] + firstPlayer.MoveDown;
            first[4] = movesName[4] + firstPlayer.HandHitLeft;
            first[5] = movesName[5] + firstPlayer.HandHitRight;
            first[6] = movesName[6] + firstPlayer.UppercodeHit;
            first[7] = movesName[7] + firstPlayer.LegHit;
            first[8] = movesName[8] + firstPlayer.Block;
            second = new String[9];
            second[0] = movesName[0] + secondPlayer.MoveLeft;
            second[1] = movesName[1] + secondPlayer.MoveRight;
            second[2] = movesName[2] + secondPlayer.MoveUp;
            second[3] = movesName[3] + secondPlayer.MoveDown;
            second[4] = movesName[4] + secondPlayer.HandHitLeft;
            second[5] = movesName[5] + secondPlayer.HandHitRight;
            second[6] = movesName[6] + secondPlayer.UppercodeHit;
            second[7] = movesName[7] + secondPlayer.LegHit;
            second[8] = movesName[8] + secondPlayer.Block;

        }
Example #4
0
	void Start(){
		playerControls = gameObject.GetComponent<PlayerControls> ();
		charStats = playerControls.characterStats;
		normalName = playerControls.controllerType+"Normal";
		specialName = playerControls.controllerType+"Special";
		horName = playerControls.controllerType+"Horizontal";
		verName = playerControls.controllerType+"Vertical";
	}
 private void PutPlayerAtTheCenterOfLevel(PlayerControls player)
 {
     player.ResetPosition ();
     if (roundScript != null)
     {
         roundScript.upScore = true;
     }
 }
Example #6
0
 public new void Start()
 {
     powerUpID = 3;
     duration = 10;
     timeLeft = this.duration;
     pc = gameObject.GetComponent<PlayerControls> ();
     ModifyObject ();
 }
Example #7
0
    // Use this for initialization
    void Start () {
        playerControls = GameObject.FindObjectOfType<PlayerControls>();
        sequenceLength = SequenceNodeTransforms.Length;
        sequenceNodes = new SequenceNode[sequenceLength];
        for (int ii = 0; ii < sequenceLength; ii++) {
            sequenceNodes[ii] = SequenceNodeTransforms[ii].GetComponent<SequenceNode>();
            sequenceNodes[ii].SetOwner(this);
        }
	}
Example #8
0
    public bool GetInputValue(PlayerControls c, out Vector3 direction)
    {
        if (c == PlayerControls.SHOOT)
            direction = _storedCameraDirection;
        else
            direction = new Vector3 (0, 0, 0);

        return inputValues[(int)c];
    }
 void RpcPickUp(NetworkInstanceId id)
 {
     if (pc == null)
         pc = ClientScene.FindLocalObject (id).GetComponent<PlayerControls> ();
     GetComponent<SpriteRenderer> ().enabled = false;
     GetComponent<CircleCollider2D> ().enabled = false;
     if (pc.isLocalPlayer)
         MainGUI.GUI.SetPowerUpIcon (Icon);
 }
    private void BumpPlayer(PlayerControls player)
    {
        player.Bump(this.transform.position, bumpForce);

        if (this.gameObject.GetComponent<Animator>() != null)
        {
            this.gameObject.GetComponent<Animator>().SetTrigger("Bump");
        }
    }
Example #11
0
		public void SetUp()
		{
			if (!IsMockResolver)
				return; //ncrunch: no coverage
			controlledPlayer = new PlayerPlane(Vector2D.Half);
			playerControls = new PlayerControls(controlledPlayer);
			keyboard = (MockKeyboard)Resolve<Keyboard>();
			originalVelocity = controlledPlayer.Get<Velocity2D>().Velocity;
		}
Example #12
0
	// Use this for initialization
	void Start () {
		player1 = GameObject.Find("Player1");
		player2 = GameObject.Find("Player2");
		player3 = GameObject.Find("Player3");
		player4 = GameObject.Find("Player4");
		
		control = GameObject.Find("Main Camera").GetComponent<PlayerControls>();
		
		
	}
Example #13
0
 // Use this for initialization
 void Start()
 {
     rb = gameObject.GetComponent<Rigidbody> ();
     pc = gameObject.GetComponent<PlayerControls> ();
     foreach (GameObject pad in GameObject.FindGameObjectsWithTag("Bouncy")) {
         Material currMat = pad.GetComponent<MeshRenderer>().material;
         currMat.EnableKeyword("_EMISSION");
         currMat.SetColor("_EmissionColor", Color.black);
     }
     bounceVector = new Vector3 (0, bouncyForce, 0);
 }
 void Start()
 {
     pc = player.GetComponent<PlayerControls> ();
     l2sc = comicUI.GetComponent<Level2_ShowComic> ();
     string endLinesStr = endLines.text;
     char[] delimitingChars = {'\n'};
     endLinesA = endLinesStr.Split (delimitingChars);
     ch = chatHandlerObj.GetComponent<ChatHandler> ();
     aus = audioObj.GetComponent<AudioSource> ();
     amount = aus.volume / 4;
     baseVolume = aus.volume;
 }
Example #15
0
    // Use this for initialization
    void Start()
    {
        startValor = Random.Range(0, 10);
        timeElapsed = Time.time;
        player = GameObject.FindGameObjectWithTag("Player");
        playerControls  = player.GetComponent<PlayerControls>();

        chickenAnimator = GetComponent<Animator>();

        float rdmScale = Random.Range(0.8f, 1.2f);
        transform.localScale *= rdmScale;
    }
Example #16
0
 public void Make(PlayerControls.Player player)
 {
     switch (player)
     {
     case PlayerControls.Player.one:
         One();
         break;
     case PlayerControls.Player.two:
         Two();
         break;
     }
 }
Example #17
0
 public void InitPlayer(Camera cam, int n, Material m, bool ctrl)
 {
     //n = 5 - n;
     gameObject.name = "Player" + n;
     PC = new PlayerControls(5-n);
     //PC = new PlayerControls(5 - n);
     material = m;
     var renderers = GetComponentsInChildren<Renderer>();
     foreach (var r in renderers)
         r.material = m;
     this.Controlled = ctrl;
 }
 // Update is called once per frame
 void Update()
 {
     if (transform.parent == null) {
         GameObject Player = ClientScene.FindLocalObject (PlayerNetId);
         if (Player != null) {
             pc = Player.GetComponent<PlayerControls> ();
             if (isRightArm)
                 pc.ConfigureRightArm (transform);
             else
                 pc.ConfigureLeftArm (transform);
         }
     }
 }
Example #19
0
    private void RpcAttachSkill(NetworkInstanceId i_PlayerID)
    {
        player = ClientScene.FindLocalObject(i_PlayerID);
        transform.SetParent(player.transform);
        m_PlayerObject = transform.root.GetComponentInChildren<PlayerControls>();
        m_AttachedToPlayer = true;
        m_Collider.enabled = false;
        //m_Renderer.enabled = false;

        transform.FindChild(ConstParams.BoxPrefab).gameObject.SetActive(false);

        OnAttachedToPlayer();
    }
Example #20
0
    protected void RpcDetachSkill()
    {
        transform.position = new Vector3(-1337, -1337, -1337);
        transform.SetParent(null);
        m_AttachedToPlayer = false;
        m_Collider.enabled = true;
        //m_Renderer.enabled = true;

        StopAllCoroutines();

        OnDetachedFromPlayer();
        m_PlayerObject = null;
        gameObject.SetActive(false);
    }
Example #21
0
    void Start()
    {
        server = new WebSocketServer(Port);
        server.KeepClean = false;
        server.AddWebSocketService<WebServer>("/Simulator");
        server.Start();

        GameObject go = gameObject;
        playerController = (PlayerControls)go.GetComponent(typeof(PlayerControls));

        //Uncomment if you want to construct a debug class that sends commands to the server
        //var testClient = new WebtestClient("80");
        //testClient.delayedMessage("forward", 1000);
        //testClient.delayedMessage("forward", 2000);
        //testClient.delayedMessage("GetSonar", 3000);
        //testClient.delayedMessage("forward", 3200);
    }
Example #22
0
    void Awake()
    {
        distance = defaultSpeed * timeLimit;
        toWayTimeLimit = timeLimit * 2;
        initReverseTime = Time.time + 5;
        if (Instance != null)
        {
            Debug.LogError("Multiple instances of Difficulty!");
        }


        groundScrollingScript = GameObject.Find("Ground").GetComponent<ScrollingScript>();
        backgroundScrollingScript = GameObject.Find("ScrollingBackground").GetComponent<ScrollingScript>();
        playerControl = GameObject.Find("RunningPlayer").GetComponent<PlayerControls>();

        Instance = this;
    }
    void OnTriggerEnter(Collider c)
    {
        if (c.gameObject.tag == "Player") {
            if (!doOnce1){
                c.transform.GetChild(0).gameObject.SetActive(true);
                comicUI.SetActive(true);
                pc = c.GetComponent<PlayerControls>();
                pc.toggleCanMove();
                doOnce1 = true;

                c.GetComponent<Rigidbody>().velocity = Vector3.zero;

                Vector3 newPos = transform.position;
                newPos.y -= 100;
                transform.position = newPos;
            }
        }
    }
    // Update is called once per frame
    public Vector3 CalculatePosition(Vector3 camPos)
    {
        if (player == null || !TrackPlayer)
            return new Vector3 (0, 5, -100);

        if (pc == null)
            pc = player.GetComponent<PlayerControls> ();

        if (pc.Alive)
            lastPlayerPosition = player.position;

        Vector3 mousePos = Camera.main.ScreenToWorldPoint (Input.mousePosition);

        Vector3 size = Camera.main.ScreenToWorldPoint (new Vector3 (Camera.main.pixelWidth, Camera.main.pixelHeight, 0))
            - Camera.main.ScreenToWorldPoint (new Vector3 (0, 0, 0));
        float mousePercentageFromCenterX = Mathf.Abs (mousePos.x - transform.position.x) / size.x;
        float mousePercentageFromCenterY = Mathf.Abs (mousePos.y - transform.position.y) / size.y;

        /* Center camera between player and mouse*/
        Vector3 midPos = (mousePos - lastPlayerPosition).normalized;
        midPos.x *= mousePercentageFromCenterX * CamDistance;
        midPos.y *= mousePercentageFromCenterY * CamDistance;
        midPos += lastPlayerPosition;
        midPos.z = transform.position.z;

        return Vector3.Lerp (camPos, midPos, lerpSpeed);

        /* Center between player and mouse, not relative to mouse distance from player
        Vector3 midPos = (mousePos - player.position).normalized * 6 + player.position;
        midPos.z = transform.position.z;
        transform.position = Vector3.Lerp(transform.position, midPos, .02f); */

        /* Center to the left or right depending on direction
        float dir = 1;
        if (player.localScale.x < 1)
            dir = -1;
        Vector3 camPos = player.position;
        camPos.z = transform.position.z;
        camPos.x = camPos.x + (dir * .15f * width);
        transform.position = Vector3.Lerp (transform.position, camPos, .03f);*/
    }
	// Use this for initialization
	public void Start () {
		Transitions.Type = FadeType.Fade_In;
		Transitions.PlayTransition = true;
		Player = GameObject.FindWithTag("Player").GetComponent<PlayerControls>();
		if (SceneManager.GetActiveScene().buildIndex == 2)
		{
			Healthbar.Health = 100;
			Player.gameObject.GetComponent<Inventory>().Clear();
		}

		if (SceneManager.GetActiveScene().buildIndex == 15)
		{
			PriestNPC = GameObject.Find("PriestNPC");
			goodNPC = GameObject.Find("GoodGuyNPC");
			Npcs.Add(goodNPC);
			goodNPC.SetActive(false);
		}

		for (int i = 0; i < 40; i++)
			Items.Add(new Item(ItemType.EMPTY));
	}
Example #26
0
	// Use this for initialization
	void Start () {
		player1 = GameObject.Find("Player1");
		player2 = GameObject.Find("Player2");
		player3 = GameObject.Find("Player3");
		player4 = GameObject.Find("Player4");
		
		control = GameObject.Find("Main Camera").GetComponent<PlayerControls>();
		
		transform.position = new Vector3(0, 1, 0);
		
		Vector3 force = new Vector3(Random.value, 0, Random.value);
		if (Random.value < 0.5f) {
			force = new Vector3(-force.x, force.y, force.z);
		}
		if (Random.value < 0.5f) {
			force = new Vector3(force.x, force.y, -force.z);
		}
		force.Normalize();
		force *= powerupSpeed;
		rigidbody.AddForce(force);
	}
Example #27
0
    // Use this for initialization
    void Start()
    {
        action = this.GetComponent<Fire>();
        movement = this.GetComponent<PlayerControls>();
        myView = this.GetComponent<PhotonView>();

        controls = this.transform.parent.GetComponentsInChildren<Transform>();

        foreach( Transform child in controls){
            if(child.CompareTag("touchGUI")){
                  GUIControls = child.gameObject;
            }
        }

        winds  = this.transform.parent.GetComponentsInChildren<Transform>();

        foreach( Transform child in winds){
            if(child.CompareTag("windGenerator")){
                  windGen = child.gameObject;
            }
        }

        windDisplays  = this.transform.parent.GetComponentsInChildren<Transform>();

        foreach( Transform child in windDisplays){
            if(child.CompareTag("windBar")){
                  windBar = child.gameObject;
            }
        }

        tags = GetComponentInChildren<Transform>();

        foreach( Transform child in tags){
            if(child.CompareTag("nametag")){
                  nameTag = child.gameObject;
            }
        }

        nameTag.GetComponent<TextMesh>().text = myView.owner.name;
    }
Example #28
0
	public List<GameObject> AllTiles;                         //All of the tiles



	private void Start()
	{
		GameManager = GameObject.Find("GameManager").GetComponent<GameManagerScript>();
		Player = GameObject.FindWithTag("Player").GetComponent<PlayerControls>();
		EnemyHolder = GameObject.Find("EnemyHolder");
		chest = Resources.Load("Chest") as GameObject;

		// Create the board holder.
		boardHolder = new GameObject("BoardHolder");
		Walls = new List<GameObject>();
		Floors = new List<GameObject>();
		AllTiles = new List<GameObject>();

		SetupTilesArray();

		CreateRoomsAndCorridors();

		SetTilesValuesForRooms();
		SetTilesValuesForCorridors();

		InstantiateTiles();
		InstantiateOuterWalls();

		SpawnEnemies();

		SpawnTreasureChests();

		//Don't spawn a ladder on the boss level, that will take the player to somewhere else.
		if (SceneManager.GetActiveScene().buildIndex != 13 && SceneManager.GetActiveScene().buildIndex != 14)
		{
			Room roomToPlaceLadderIn = rooms[numRooms.Random - 1];
			Vector3 ladderPosition = new Vector3(roomToPlaceLadderIn.xPos, roomToPlaceLadderIn.yPos, -1);
			ladder.transform.position = ladderPosition;
		}

		//Set the player's position.
		SetPlayerPosition();
	}
Example #29
0
    void Awake()
    {
        player = GetComponent<PlayerControls>();
            thisFireBtn = GetComponent<Fire>();
            cam = this.transform.parent.GetComponentInChildren<Camera>();

            if (photonView.isMine)
            {
                cam.enabled = true;
                player.enabled=true;
                player.isControllable=true;
                thisFireBtn.isControllable=true;
            }
            else
            {
                cam.enabled = false;
                player.enabled=true;
                player.isControllable=false;
                thisFireBtn.isControllable=false;
            }

            gameObject.name = gameObject.name + photonView.viewID;
    }
        public EconomyController(GameState game, Id<Player> player, PlayerGameView view)
            : base(game)
        {
            this.view = view;
            this.player = game.Players[player];
            this.economy = game.Economies.First(e => e.Player == this.player);
            this.body = this.economy.Body;

            view.FocusOnBody(this.body);

            this.controls = new PlayerControls();

            this.stats = new[]
            {
                new EcoStatController(this.game, this, this.economy, EcoValue.Income,
                    KeyboardAction.FromKey(Key.Number1),KeyboardAction.FromKey(Key.Number2), "1<>2"),
                new EcoStatController(this.game, this, this.economy, EcoValue.Projectiles,
                    KeyboardAction.FromKey(Key.Q),KeyboardAction.FromKey(Key.W), "Q<>W"),
                new EcoStatController(this.game, this, this.economy, EcoValue.FireRate,
                    KeyboardAction.FromKey(Key.A),KeyboardAction.FromKey(Key.S), "A<>S"),
                new EcoStatController(this.game, this, this.economy, EcoValue.Defenses,
                    KeyboardAction.FromKey(Key.Z),KeyboardAction.FromKey(Key.X), "Z<>X"),
            };
        }
Example #31
0
 private void Awake()
 {
     control = new PlayerControls();
     control.controls.Move.performed   += ctx => moveInput = ctx.ReadValue <Vector2>();
     control.controls.sprint.performed += ctx => sprintInput = ctx.ReadValue <float>();
 }
Example #32
0
 void OnEnable()
 {
     controls = FindObjectOfType <PlayerControlsManager>().GetControls();
     PopulateLexikon();
 }
Example #33
0
        public bool Lockon;                     //this would be used to switch to a virtual camera for a lockon system

        private void Awake() => defaultcontrols = new PlayerControls();
Example #34
0
    IEnumerator CoUpdate()
    {
        while (thisTransform)
        {
            //if (playerTransform)


            switch (currentState)
            {
            case EnemyState.StandBy:
                if (!playerTransform)
                {
                    if (Managers.Game.PlayerPrefab)
                    {
                        playerTransform = Managers.Game.PlayerPrefab.transform;                                 //	We can Use this system to get the player's Id & position
                        playerControl   = playerTransform.GetComponent <PlayerControls>();
                        //playerProps = playerTransform.GetComponent<PlayerProperties>();
                        currentState = EnemyState.Roaming;
                    }
                    else
                    {
                        yield return(0);
                    }
                }
                break;

            case EnemyState.Roaming:
                distanceToTarget = Vector3.Distance(playerTransform.position, thisTransform.position);

                if (distanceToTarget <= searchRange)                                // SI distancia al objetivo es menor que el rango de busqueda..
                {
                    if (distanceToTarget <= attackRange &&   //)
                        thisTransform.position.y >= playerTransform.position.y + 1)                                 // si está dentro de rango de ataque..
                    {
                        currentState = EnemyState.Attacking;                                                        // acelerar la velocidad de ataque
                    }
                    else
                    {
                        ChasePlayer();                                                          // sino continuar rastreandolo a velocidad normal
                    }
                }
                else                                                                                        // SINO chequear rutina habitual de comportamiento cuando está solo...
                {
                    GoHome();                                                                               // Volver a casa! ( cambia dirección de lado y avanzar indefinidamente..
                }
                break;

            case EnemyState.Attacking:
                AttackPlayer();
                break;

            case EnemyState.Hooked:
                if (Input.anyKeyDown || Managers.Game.InputLeft || Managers.Game.InputRight ||
                    Managers.Game.InputDown || Managers.Game.InputUp || Input.GetButtonDown("Fire1") ||
                    Input.GetButtonDown("Fire2") || Input.GetButtonDown("Jump"))
                {
                    ReleaseKeys++;
                }

                //if (Time.time > timeLapse)
                //{
                //    timeLapse = Time.time + 3;
                //    collider.enabled = true;
                //}

                //thisTransform.position = playerTransform.position;
                //thisTransform.position += (Vector3.up * Mathf.Sin(Time.time * 5) * 3 * Time.deltaTime);
                thisTransform.position += (Vector3.up * Mathf.Sin(Time.time * 15) * Time.deltaTime);

                orientation = playerControl.orientation;
                //aniPlay.PlayFrames(5, 5, 2, orientation);
                aniPlay.PlayFramesFixed(5, 5, 2, orientation, 1);

                timeLapse -= Time.deltaTime;

                if (ReleaseKeys > 30 || timeLapse <= 0)
                {
                    BeatDown();
                }

                break;

            case EnemyState.Holded:
                thisTransform.position = playerTransform.position + HoldedPosition;             // Update own hold position & player's too
                BeingHolded();
                break;

            case EnemyState.Shooted:
                if (playerTransform)
                {
                    if (thisTransform.IsChildOf(playerTransform))                                                               // check if the player has taken us...
                    {
                        currentState = EnemyState.Holded;                                                                       // & change enemy state to holded..
                    }
                }
                thisTransform.RotateAround(Vector3.forward, -orientation * 45 * Time.deltaTime);
                velocity.y             -= gravity * Time.deltaTime;
                thisTransform.position += velocity * Time.deltaTime;

                break;

            case EnemyState.Dead:
                if (playerTransform)
                {
                    if (thisTransform.IsChildOf(playerTransform))                                                               // check if the player has taken us...
                    {
                        currentState = EnemyState.Holded;                                                                       // & change enemy state to holded..
                    }
                }
                thisTransform.RotateAround(Vector3.forward, -orientation * 45 * Time.deltaTime);
                velocity.y             -= gravity * Time.deltaTime;
                thisTransform.position += velocity * Time.deltaTime;

                if (thisTransform.position.y < 0 && thisTransform != null)
                {
                    Destroy(gameObject, 2);     // If character falls get it up again
                }
                break;
            }

            yield return(0);
        }
    }
Example #35
0
 void Start()
 {
     controls       = new PlayerControls();
     playerMovement = GetComponent <PlayerMovement>();
 }
Example #36
0
 // Start is called before the first frame update
 void Start()
 {
     controls = GetComponent <PlayerControls>();
 }
 private void Awake()
 {
     PlayerAction = new PlayerControls();
 }
    void Awake()
    {
        Instance = this;

        playerControls = GetComponentInParent <PlayerControls>();
    }
 private void Awake()
 {
     playerControls = new PlayerControls();
 }
 // Start is called before the first frame update
 void Start()
 {
     player    = GameObject.FindObjectOfType <PlayerControls>();
     character = GameObject.Find("Player");
 }
Example #41
0
 public void FindPlayer()
 {
     thePlayer          = PlayerControls.Instance;
     lastPlayerPosition = thePlayer.transform.position;
 }
Example #42
0
    // private bool CanShoot()
    // {
    //     //return PlayerEvents.Current.hasAmmo && !PlayerEvents.Current.isGrabbing;
    // }
    public override InputAction MyInput()
    {
        PlayerControls _playerControls = new PlayerControls();

        return(_playerControls.Player.Primary_Fire);
    }
Example #43
0
 void Awake()
 {
     controls = new PlayerControls();
     controls.Game.SetCallbacks(this);
 }
Example #44
0
 void InitialiseControls()
 {
     controlsDict = PlayerControls.GetPlayerControls(playerId - 1);
 }
Example #45
0
 private void Awake()
 {
     playerControls = new PlayerControls();
     playerControls.Shooting.AimingMouse.performed      += ctx => AimingMouse(ctx.ReadValue <Vector2>());
     playerControls.Shooting.AimingController.performed += ctx => AimingController(ctx.ReadValue <Vector2>());
 }
 void Start()
 {
     output         = GetComponent <Text>();
     playerControls = FindObjectOfType <PlayerControls>();
 }
Example #47
0
 // Use this for initialization
 void Start()
 {
     playerControlScript = GameObject.Find("PlayerCharacter").GetComponent <PlayerControls>();
     rigBod = GetComponent <Rigidbody>();
     col    = GetComponent <BoxCollider>();
 }
Example #48
0
 void Awake()
 {
     control = new PlayerControls();
     control.Player.Shoot.performed += ctx => GetInput(ctx);
 }
Example #49
0
 private void Awake()
 {
     input = new PlayerControls();
 }
Example #50
0
 void Awake()
 {
     controls = new PlayerControls();
     controls.LookAround.Rotation.performed += ctx => move = ctx.ReadValue <Vector2>();
     controls.LookAround.Rotation.canceled  += ctx => move = Vector2.zero;
 }
 public PlayerShiftEvent(PlayerControls _player, bool _currentlyReversed)
 {
     player            = _player;
     currentlyReversed = _currentlyReversed;
 }
Example #52
0
    IEnumerator CoUpdate()
    {
        while (thisTransform)
        {
            switch (currentState)
            {
            case EnemyState.StandBy:
                if (!playerTransform)
                {
                    if (Managers.Game.PlayerPrefab)
                    {
                        playerTransform = Managers.Game.PlayerPrefab.transform;                                 //	We can Use this system to get the player's Id & position
                        playerControl   = playerTransform.GetComponent <PlayerControls>();
                        currentState    = EnemyState.Roaming;
                    }
                    else
                    {
                        yield return(0);
                    }
                }
                break;

            case EnemyState.Roaming:
                if (!playerTransform)
                {
                    break;
                }

                distanceToTarget = Vector3.Distance(playerTransform.position, thisTransform.position);

                if (distanceToTarget <= searchRange)                                                                   // SI distancia al objetivo es menor que el rango de busqueda..
                {
                    if (distanceToTarget <= attackRange && thisTransform.position.y >= playerTransform.position.y + 1) // si está dentro de rango de ataque..
                    {
                        currentState = EnemyState.Attacking;                                                           // acelerar la velocidad de ataque
                    }
                    else
                    {
                        ChasePlayer();                                                          // sino continuar rastreandolo a velocidad normal
                    }
                }
                else                                                                                        // SINO chequear rutina habitual de comportamiento cuando está solo...
                {
                    GoHome();                                                                               // Volver a casa! ( cambia dirección de lado y avanzar indefinidamente..
                }
                break;

            case EnemyState.Attacking:
                AttackPlayer();
                break;


            case EnemyState.Holded:
                thisTransform.position = playerTransform.position + HoldedPosition;             // Update own hold position & player's too
                BeingHolded();
                break;

            case EnemyState.Shooted:
                if (playerTransform)
                {
                    if (thisTransform.IsChildOf(playerTransform))                                                               // check if the player has taken us...
                    {
                        currentState = EnemyState.Holded;                                                                       // & change enemy state to holded..
                    }
                }
                thisTransform.RotateAround(Vector3.forward, -orientation * 45 * Time.deltaTime);
                velocity.y             -= gravity * Time.deltaTime;
                thisTransform.position += velocity * Time.deltaTime;

                break;

            case EnemyState.Dead:
                if (playerTransform)
                {
                    if (thisTransform.IsChildOf(playerTransform))                                                               // check if the player has taken us...
                    {
                        currentState = EnemyState.Holded;                                                                       // & change enemy state to holded..
                    }
                }
                thisTransform.RotateAround(Vector3.forward, -orientation * 45 * Time.deltaTime);
                velocity.y             -= gravity * Time.deltaTime;
                thisTransform.position += velocity * Time.deltaTime;

                if (thisTransform.position.y < 0 && thisTransform != null)                          // If player was killeds
                {
                    timeSpawn -= Time.deltaTime;

                    if (timeSpawn <= 0)
                    {
                        timeSpawn = Random.Range(1, 3);

                        velocity = Vector3.zero;
                        thisTransform.rotation = Quaternion.Euler(Vector3.zero);
                        gameObject.tag         = "Enemy";
                        thisTransform.parent   = Managers.Tiled.MapTransform;
                        currentState           = EnemyState.Roaming;
                        thisTransform.position = homePosition;
                        Destroy(Instantiate(ParticleStars, thisTransform.position, thisTransform.rotation), 5);
                        searchRange = Random.Range(10, 100);

                        Debug.Log("Dengue Respawned");
                    }
                }
                //Destroy(gameObject, 2);	// If character falls get it up again

                break;
            }

            yield return(0);
        }
    }
Example #53
0
 void Start()
 {
     player = GameObject.Find("Player Model").GetComponent <PlayerControls>();
     song   = GameObject.Find("Background").GetComponent <songControl3>();
 }
Example #54
0
 void Awake()
 {
     menu = GameObject.Find("Pause Menu");
     menu.SetActive(false);
     player = GameObject.Find("Player").GetComponent <PlayerControls>();
 }
Example #55
0
    // 0 = general UI
    // 1 = keyboard controls
    // 2 = gamepad controls
    // 3 = settings
    // 4 = about

    private void Awake()
    {
        controls = new PlayerControls();    // Initialize our controls object
        controls.Gameplay.PauseGame.performed += ctx => GamePause();
        Cursor.lockState = CursorLockMode.Locked;
    }
 void Awake()
 {
     input = new PlayerControls();
     input.Combat.SetCallbacks(this);
 }
 // Use this for initialization
 void Start()
 {
     Player         = GameObject.FindGameObjectWithTag("Player");
     playerControls = Player.GetComponent <PlayerControls>();
 }
Example #58
0
 public GameplayActions(PlayerControls wrapper)
 {
     m_Wrapper = wrapper;
 }
Example #59
0
 public void ToggleBotSelector(PlayerControls bot, bool isOn = true)
 {
     botSelectors[bot.BotType].SetActive(isOn);
 }
Example #60
0
    private void Awake()
    {
        playerControls = new PlayerControls();

        playerControls.Dialog.StartDialog.performed += ctx => StartDialog();
    }