// Use this for initialization void Start() { an = GetComponent <Animator>(); rb = GetComponent <Rigidbody2D>(); sr = GetComponent <SpriteRenderer>(); PcS = GetComponent <ControllerPlayer>(); }
// Use this for initialization void Start() { if (!g_player) { g_player = this; } else { Destroy(this.gameObject); return; } m_grabbed = false; m_stamina = 1000.0f; com_rigidbody = GetComponent <Rigidbody>(); com_sphereColl = GetComponent <SphereCollider>(); m_jumping = false; m_distToGround = GetComponent <Collider>().bounds.extents.y; m_hasControl = true; key_left = KeyCode.A; key_right = KeyCode.D; key_up = KeyCode.W; key_down = KeyCode.S; key_jump = KeyCode.Space; key_mb_right = 1; m_deadZone = 0.25f; m_speed = 5.0f; m_jumpForce = 250.0f; }
public void SetValues(GameObject player) { this.player = player; controllerPlayer = this.player.GetComponent <ControllerPlayer>(); //Debug.Log("Set Player Info ! "); }
public void UpdateInputMode(UnitPlayer _Player, ControllerPlayer _Controller) { if (Input.touchCount >= 1) { Touch touch = Input.touches[0]; if (!m_HasStartedSlash) { m_HasStartedSlash = true; m_SlashStartPosition = touch.position; } UserInterface.DisplaySlashLine(m_SlashStartPosition, touch.position); if (touch.phase == TouchPhase.Canceled) { m_HasStartedSlash = false; UserInterface.HideSlashLine(); } else if (touch.phase == TouchPhase.Ended) { m_HasStartedSlash = false; if (UserInterface.IsMeleeSlashHitting(m_SlashStartPosition, touch.position)) { _Player.AttackEnemy(); } UserInterface.HideSlashLine(); } } }
public MainWindow() { controller = new ControllerPlayer(); viewModel = new ViewModelPlayer(); InitializeComponent(); this.DataContext = viewModel; }
void Start() { m_controllerPlayer = GetComponent <ControllerPlayer>(); m_controllerWallClimbing = GetComponent <ControllerWallClimbing>(); m_controllerLedgeClimbing = GetComponent <ControllerLedgeClimbing>(); m_collider = GetComponent <CapsuleCollider>(); m_currentState = ClimbingState.NotClimbing; }
void revive() { close(); //gets player ControllerPlayer player = GameObject.FindGameObjectWithTag("Player").GetComponent <ControllerPlayer>(); //heals player player.heal(10f); //kills all enemies in a 3 unit radius //creates layer mask LayerMask mask = 1 << 9; //creates filter ContactFilter2D filter = new ContactFilter2D(); filter.SetLayerMask(mask); filter.ClearDepth(); filter.useTriggers = true; //creates array Collider2D[] colliders = new Collider2D[30]; //puts into array all the overlapping colliders Physics2D.OverlapCircle(player.transform.position, 3f, filter, colliders); //adds colliders into list foreach (Collider2D collide in colliders) { //tests if the collider is null if (collide == null) { continue; } //tests if the collider is a trigger if (collide.isTrigger) { continue; } //tests if the collider is a hitbox by checking if it is a box2d if (collide is BoxCollider2D) { EnemyMovement enemy = collide.gameObject.GetComponent <EnemyMovement>(); if (enemy != null) { enemy.damage(1f); } } } //revive Animation player.reviveAni(); wasPreviouslyRevived = true; }
void Awake() { player = ReInput.players.GetPlayer(0); if (Singleton == null) { Singleton = this; } }
private void btnPlay_Click(object sender, EventArgs e) { try { if (EmptyNicknameException(txtNickname.Text)) { //Verifys that text added in the textbox is not empty throw new EmptyNicknameException("Text can't be empty"); } if (MaxCharactersException(txtNickname.Text)) { //Verifys that text added in the textbox is not more than 15 characters throw new MaxCharactersException("Text can't have more than 15 characters"); } if (WrongCharactersException(txtNickname.Text)) { //Verifys that text added in the textbox is not a symbol throw new WrongCharactersException("Text can only have alphanumeric and numeric characters"); } string aux = txtNickname.Text; try { foreach (var player in ControllerPlayer.NicknameList()) { if (player.nickname.Equals(aux)) { StaticAttributes.nicknameRepeated = true; } } } catch (Exception) { MessageBox.Show("error"); } Game game = new Game(aux); game.Show(); Hide(); } catch (EmptyNicknameException exc) { MessageBox.Show(exc.Message); } catch (MaxCharactersException exc) { MessageBox.Show(exc.Message); } catch (WrongCharactersException exc) { MessageBox.Show(exc.Message); } catch (Exception) { MessageBox.Show("An error has occurred"); } }
void Start() { controllerPlayer = GetComponent <ControllerPlayer> (); ringRadius = ring.GetComponent <Collider> ().bounds.max.x / 2; escapeDirections [0] = new Vector3(ringRadius * 2, .5f, 0); escapeDirections [1] = new Vector3(-ringRadius * 2, .5f, 0); escapeDirections [2] = new Vector3(0, .5f, ringRadius * 2); escapeDirections [3] = new Vector3(0, .5f, -ringRadius * 2); ClosestPlayer(); }
// FUNCTIONS // // Initialization private void Awake() { Instance = this; playerAgent = GetComponent <NavMeshAgent>(); cameraDirection = Camera.main.transform; currentTransform = GetComponent <Transform>(); animator = GetComponent <Animator>(); playerStats = GetComponent <ObjectStats>(); }
void Start(){ //Set state character instace = this; characterController = this.GetComponent<CharacterController>(); animationManager = this.GetComponent<AnimationManager>(); speedMove = GameAttribute.gameAttribute.speed; jumpSecond = false; magnet.SetActive(false); Invoke("WaitStart",0.2f); }
// Start is called before the first frame update void Start() { rb = GetComponent <Rigidbody>(); rb.freezeRotation = true; GameObject playerObj = GameObject.FindGameObjectWithTag("Player"); player = playerObj.GetComponent <ControllerPlayer>(); rotOriginal = transform.localRotation; }
private void OnTriggerEnter2D(Collider2D collision) { //Debug.Log("Name : BOSSMissile - " + collision.tag); if (this.tag == "Missile") { this.gameObject.transform.rotation = Quaternion.Euler(new Vector3(0, 0, 0)); if (collision.tag == "WasteBasket") { Destroy(this.gameObject); } switch (collision.tag) { case "Player": //case "WasteBasket": //Debug.Log("If Player : " +collision.tag); Instantiate(missileExplosion, this.transform.position, Quaternion.identity); PublicValueStorage.Instance.GetPlayerComponent().ActivatePlayerDie(); Destroy(this.gameObject); break; case "PlayerShield": this.tag = "PlayerMissile"; this.name = "PlayerMissile"; //enemyTrail.enabled = true; //missileColor.color = Color.blue; //Debug.Log(missileColor); //GameManager.Instance.ScoreAdd("Missile"); ControllerPlayer tempPlayer = PublicValueStorage.Instance.GetPlayerComponent(); PublicValueStorage.Instance.AddMissileScore(); tempPlayer.OP_DamageToPlayerShield(missileShieldBreakPercent); tempPlayer.DamageToShieldForLineFallMissile(); direction = opCurves.SeekDirection(this.gameObject.transform.position, parentPos); missileCurrentSpeed *= missileReflectSpeed; break; } } else if (this.tag == "PlayerMissile") { if (collision.tag == "WasteBasket") { Destroy(this.gameObject); } switch (collision.tag) { case "Enemy": case "BOSS": Instantiate(missileExplosion, this.transform.position, Quaternion.identity); Destroy(this.gameObject); break; } } }
void Start() { //Set state character instace = this; characterController = this.GetComponent <CharacterController>(); animationManager = this.GetComponent <AnimationManager>(); speedMove = GameAttribute.gameAttribute.speed; jumpSecond = false; magnet.SetActive(false); Invoke("WaitStart", 0.2f); }
public override void ActivateEvent(I_Unit _UnitThatWalkedOnTile) { if (_UnitThatWalkedOnTile is UnitPlayer) { UnitPlayer player = _UnitThatWalkedOnTile as UnitPlayer; m_Player = player.GetComponent <ControllerPlayer>(); m_Player.SetInputMode(new InputMode_InMenu()); List <KeyValuePair <string, OnUserInterfaceButtonPressed> > menuElements = new List <KeyValuePair <string, OnUserInterfaceButtonPressed> > { new KeyValuePair <string, OnUserInterfaceButtonPressed>("Proceed", GoToNextFloor), new KeyValuePair <string, OnUserInterfaceButtonPressed>("Exit", ExitMenu) }; UserInterface.DisplayMenu(menuElements); } }
public void UpdateInputMode(UnitPlayer _Player, ControllerPlayer _Controller) { if (m_HasStartedShaking) { if (m_TimerBeforeCanChangeDirection > 0) { m_TimerBeforeCanChangeDirection -= Time.unscaledDeltaTime; } else { UserInterface.SetBellRing(); } float newValue = Input.acceleration.z; if (m_WasGoingForward && newValue > m_LastValue + Time.unscaledDeltaTime * 3 || !m_WasGoingForward && newValue < m_LastValue - Time.unscaledDeltaTime * 3) { m_TimeGoingTheSameDirection += Time.unscaledDeltaTime; } else if (m_WasGoingForward && newValue < m_LastValue || !m_WasGoingForward && newValue > m_LastValue) { if (m_TimerBeforeCanChangeDirection <= 0) { m_TimerBeforeCanChangeDirection = 0.25f; if (m_TimeGoingTheSameDirection > 0.08f) { if (newValue < m_LastValue) { UserInterface.SetBellRingLeft(); } else { UserInterface.SetBellRingRight(); } m_NumberTimesShaked++; if (m_NumberTimesShaked > 10) { m_HasStartedShaking = false; for (int i = 0; i < m_Activables.Count; i++) { m_Activables[i].OnActivation(); } _Controller.SetInputMode(new InputMode_Movement()); } } } m_TimeGoingTheSameDirection = 0; m_WasGoingForward = !m_WasGoingForward; } m_LastValue = newValue; } }
// 190122 LifeBalance // When game is over, Reset all parameter (will) public void ResetGame() { Destroy(player.gameObject); player = Instantiate(playerPrefab, playerPrefab.transform.position, Quaternion.Euler(0, 0, 0)); playerScript = player.GetComponent <ControllerPlayer>(); playerScript.SetCallbacks(CBPlayerDie, CBGetItem, CBChangeGameStart); //playerScript.SetCallback(0, CBPlayerDie); //playerScript.SetCallback(1, CBGetItem); //player.GetComponent<ControllerPlayer>().SetCallback(0, PlayerDie); playerPos = player.transform.position; Lobby.SetCallBacksTest(CBGameStart); player.transform.position = playerSlot.transform.position; PublicValueStorage.Instance.SetValues(player); PublicValueStorage.Instance.SetAddSpeedRivisionValue(1.0f); gamePlayUI.SetActive(false); Lobby.gameObject.SetActive(true); createdEnemies = 0; enemyPos.Clear(); CompareBestScore(); creditboardInUI.text = "" + credit; score = 0; scoreboard.text = "" + score; levelWithDiedEnemy = 0; SaveData.Instance.SaveUserData(); onPlayerDie = null; isBossAlive = false; if (onDestroyAllObject != null) { onDestroyAllObject(); onDestroyAllObject = null; } ChangeGameState(GameState.Lobby); SoundManager.Instance.BgmSpeaker(SoundManager.BGM.Lobby, SoundManager.State.Play); }
private void Collider2D_Tick(object sender, EventArgs e) { //Bricks collider if (GameData.gameInitiated) { int xAxis = 10; int yAxis = 4; for (int j = yAxis - 1; j >= 0; j--) { for (int i = 0; i < xAxis; i++) { if (bricksMatrix[i, j] != null) { if (mario.Bounds.IntersectsWith(bricksMatrix[i, j].Bounds)) { bricksMatrix[i, j].hits--; if (bricksMatrix[i, j].hits == 1) { bricksMatrix[i, j].BackgroundImage = Image.FromFile("../../Resources/Bricks/brokenBrick.png"); player.score = Convert.ToString($"Score: {Convert.ToInt32(player.score.Substring(6)) + 100}"); } else { Controls.Remove(bricksMatrix[i, j]); bricksMatrix[i, j] = null; player.score = Convert.ToString($"Score: {Convert.ToInt32(player.score.Substring(6)) + 100}"); number_of_bricks--; if (number_of_bricks == 0) { StaticAttributes.finished = true; var NewScore = (Convert.ToInt32(player.time.Substring(5)) + Convert.ToInt32(player.score.Substring(6))) * (Convert.ToInt32(player.lives.Substring(1)) + 1); if (!StaticAttributes.nicknameRepeated) { ControllerPlayer.AddNickname(player.nickname); } ControllerPlayer.AddScore(player.nickname, NewScore); Congratulations congratulations = new Congratulations(player); congratulations.Show(); Hide(); } } GameData.dirY *= -1; return; } } } } } }
private void OnEnable() { GameManager.onDestroyAllObject += OnDestroyAllObject; GameManager.onPlayerDie += OnPlayerDie; GameManager.onDestroyAllEnemy += OnPlayerDie; if (this.tag != "LineFallSlowRailGun") { GameManager.onDeadByItemBomb += OnPlayerDie; } if (this.tag == "LineFallSlowRailGun") { player = PublicValueStorage.Instance.GetPlayerComponent(); } }
void Start() { if ((m_controllerPlayer = GetComponent <ControllerPlayer>()) == null) { print("ControllerPlayer.cs not found"); } if ((m_playerCollider = GetComponent <CapsuleCollider>()) == null) { print("Player has no collider attached"); } if ((m_playerRigidbody = GetComponent <Rigidbody>()) == null) { print("Player has no rigidbody"); } }
void FindAllControllers() { // make controllers ready for (int i = 0; i < 4; ++i) { PlayerIndex testPlayerIndex = (PlayerIndex)i; GamePadState testState = GamePad.GetState(testPlayerIndex); if (testState.IsConnected) { Debug.Log(string.Format("GamePad found {0}", testPlayerIndex)); ControllerPlayer p = new ControllerPlayer(testPlayerIndex); ControllerPlayers.Add(p); } } }
public void RemoveInputComponent(ControllerPlayer controller, InputComponent inputComponent, Controls controls) { InputManager.Instance.inputComponents[controls].Remove(inputComponent); Debug.Log("One InputComponent Removed WASD, Total=" + inputComponents[controls].Count); if (InputManager.Instance.inputComponents[Controls.WASD].Count == 0) { InputManager.Instance.inputComponents.Remove(Controls.WASD); // ServiceUI.Instance.GameOver(); } if (InputManager.Instance.inputComponents[Controls.IJKL].Count == 0) { InputManager.Instance.inputComponents.Remove(Controls.IJKL); Debug.Log("One InputComponent Removed IJKL, Total=" + inputComponents.Count); } }
public void InitModule(Vector3 spawnStart) { pattern = Pattern.Idle; player = PublicValueStorage.Instance.GetPlayerComponent(); if (player != null) { playerSpriteRenderer = player.transform.GetChild(0).GetComponent <SpriteRenderer>(); } spawnOptionPosition = spawnStart; activateModule = true; if (optionEa >= 4) { optionEa = 4; } options = new List <LaserNo5OptionVer2>(); deadOptionIndex = new List <int>(); Vector3 center = this.transform.position; float gap = PublicValueStorage.Instance.GetScreenSize().x * 0.2f; float startPositionX = center.x + (gap * (-1.5f)); for (int i = 0; i < optionEa; i++) { LaserNo5OptionVer2 temp = Instantiate(optionPrefab, spawnOptionPosition, Quaternion.Euler(Vector3.zero), this.transform); temp.gameObject.SetActive(false); options.Add(temp); temp.myIndex = i; if (i == 0 || i == optionEa - 1) { optionPositions.Add(new Vector3(startPositionX, center.y, center.z)); } else { optionPositions.Add(new Vector3(startPositionX, center.y - (gap * 1.2f), center.z)); } startPositionX += gap; } optionPositions.Add(new Vector3(gap, 0, 0)); PublicValueStorage.Instance.SetBossTransform(this.transform); }
private void GiveControllerToShips() { for (int i = 0; i < GameSettings.instance.indexController.Count; i++) { switch (GameSettings.instance.indexController[i]) { case 0: // Player ControllerPlayer player = usableSpaceships[i].AddComponent <ControllerPlayer>(); player.moveAxis = "Move" + (i + 1).ToString(); player.attackAxis = "Power" + (i + 1).ToString(); break; case 1: // AI Easy usableSpaceships[i].AddComponent <ControllerRandom>(); break; case 2: // AI Medium ControllerIAMedium medium = usableSpaceships[i].AddComponent <ControllerIAMedium>(); medium.raycastNumber = 9; break; case 3: // AI Hard ControllerIAMediumHard hard = usableSpaceships[i].AddComponent <ControllerIAMediumHard>(); hard.distanceCaptureRay = 100; hard.raycastNumber = 700; break; case 4: // Save Data Player ControllerPlayerSaveFeatures playerSaveFeatures = usableSpaceships[i].AddComponent <ControllerPlayerSaveFeatures>(); playerSaveFeatures.angleShipFieldview = 200; playerSaveFeatures.dataSavingFrequence = 5; playerSaveFeatures.nbRaycasts = 50; playerSaveFeatures.nbMaxResultsByRaycast = 1; playerSaveFeatures.moveAxis = "Move" + (i + 1).ToString(); playerSaveFeatures.attackAxis = "Power" + (i + 1).ToString(); break; case 5: usableSpaceships[i].AddComponent <ControllerIALearning>(); break; default: // Consider AI Easy usableSpaceships[i].AddComponent <ControllerRandom>(); break; } } }
public void SetPlaySettings() { player = GameObject.FindGameObjectWithTag("Player").GetComponent <ControllerPlayer>(); if (MainManager.Instance != null) { playerInfo = MainManager.Instance.GetPlayerInfo(); player.SetPlayerInfo(playerInfo.shieldDuration, MainManager.Instance.GetPlayerSprite(), playerInfo.itemSlot, playerInfo.lifeTime); } else { Sprite mySpr = Sprite.Create(Texture2D.whiteTexture, new Rect(Vector2.zero, new Vector2(1, 1)), Vector2.zero); Sprite[] spr = { mySpr, mySpr, mySpr }; playerInfo = new ShopManager.ItemInfo(); playerInfo.lifeTime = 600; player.SetPlayerInfo(playerInfo.shieldDuration, spr, playerInfo.itemSlot, playerInfo.lifeTime); } }
private void OnEnable() { GameManager.onPlayerDie += OnPlayerDie; //GameManager.onDestroyAllEnemy += OnPlayerDie; //GameManager.onBossDie += OnBossDie; // for debug //onBossDie += GameManager.Instance.BossDie; enemyState = EnemyState.Spawned; bezierStart = this.gameObject.transform.position; playerForRelease = PublicValueStorage.Instance.GetPlayerComponent(); }
public void UpdateInputMode(UnitPlayer _Player, ControllerPlayer _Controller) { if (Input.GetKeyDown(KeyCode.Mouse0)) { UserInterface.StartMagicalFormulaDrawing(new Vector2(Input.mousePosition.x, Input.mousePosition.y)); } if (Input.GetKeyUp(KeyCode.Mouse0)) { List <int> magicalFormula = UserInterface.EndMagicalFormulaDrawing(new Vector2(Input.mousePosition.x, Input.mousePosition.y)); Spell spellToCast = _Player.GetCorrespondingSpell(magicalFormula); if (spellToCast != null) { _Controller.SetInputMode(new InputMode_MovementDebug()); spellToCast.Cast(_Player); } } UserInterface.UpdateMagicalFormulaDrawing(new Vector2(Input.mousePosition.x, Input.mousePosition.y)); }
//private void Start() //{ // screenHeight = PublicValueStorage.Instance.GetScreenSize().y; // screenWidth = PublicValueStorage.Instance.GetScreenSize().x; // CreateOptionCoord(); //} public void InitBossMissileModule(float height, float width, GameObject player) { screenHeight = height; screenWidth = width; //Debug.Log("Get PlayerPos : " + height + " " + width); bossPatternState = BossPatternState.Shuffle; playerPos = player.transform.position; this.player = player.GetComponent <ControllerPlayer>(); if (spawnSpotLeft.Count == 0) { CreateOptionCoord(); } rivisionSpeed = PublicValueStorage.Instance.GetAddSpeedRivisionValue(); }
private void Awake() { leftLongAttackID = Animator.StringToHash(leftLongAttackState); leftShortFirstChainAttackID = Animator.StringToHash(leftShortFirstChainAttackState); leftShortSecondChainAttackID = Animator.StringToHash(leftShortSecondChainAttackState); leftShortThirdChainAttackID = Animator.StringToHash(leftShortThirdChainAttackState); rightLongAttackID = Animator.StringToHash(rightLongAttackState); rightShortFirstChainAttackID = Animator.StringToHash(rightShortFirstChainAttackState); rightShortSecondChainAttackID = Animator.StringToHash(rightShortSecondChainAttackState); rightShortThirdChainAttackID = Animator.StringToHash(rightShortThirdChainAttackState); animator = GetComponent <Animator>(); if (controller == null) { controller = transform.GetComponent <ControllerPlayer>(); } }
public void UpdateInputMode(UnitPlayer _Player, ControllerPlayer _Controller) { m_Direction = E_Direction.None; if (Input.GetKey(KeyCode.Z)) { m_Direction = E_Direction.North; } if (Input.GetKey(KeyCode.S)) { m_Direction = E_Direction.South; } if (Input.GetKey(KeyCode.D)) { m_Direction = E_Direction.East; } if (Input.GetKey(KeyCode.Q)) { m_Direction = E_Direction.West; } if (_Player.CanMove()) { if (m_Direction != E_Direction.None) { I_Unit unitOnTile = _Player.GetTile().GetNeighbour(m_Direction).GetUnit(); if (_Player.CanMoveTo(m_Direction)) { _Player.Move(m_Direction); TurnOrder.StartAllUnitsTurn(); } else if (unitOnTile is UnitEnemy) { _Player.SetAttackingEnemy(unitOnTile as UnitEnemy); } else { _Player.TurnToward(m_Direction); } } } _Controller.SetAnimatorBool("IsMoving", _Player.IsMoving()); }
void Start() { Screen.showCursor = false; playersChosenID = new int[4]; currentPlayersChosenSlotID = 0; selected = 0; StartGameText.SetActive(false); Glitch = gameObject.GetComponent<GlitchEffect>(); //iTween.RotateTo(gameObject, iTween.Hash("rotation", transform.position, iTween.EaseType.easeInOutSine, "time", 1.3f)); //iTween.RotateBy(gameObject, iTween.Hash("y", .25, "easeType", "easeInOutBack", "loopType", iTween.LoopType.none, "delay", .4)); // make controllers ready ControllerPlayers = new List<ControllerPlayer>(); for (int i = 0; i < 4; ++i) { PlayerIndex testPlayerIndex = (PlayerIndex)i; ControllerPlayer p = new ControllerPlayer(testPlayerIndex); ControllerPlayers.Add(p); } // make cameras ready currentSlots = new int[4]; readyToMoveSlot = new bool[4]; MyCharacter = new RunAnimDummy[4]; OriginalScales = new Vector3[4]; OriginalPositions = new Vector3[4]; for (int i = 0; i < 4; i++) { FourCamerasSpots[i].transform.position = FourSlots[i].transform.position; currentSlots[i] = i; OriginalScales[i] = PlaneSlots[i].transform.localScale; OriginalPositions[i] = PlaneSlots[i].transform.position; readyToMoveSlot[i] = false; } selected = 0; }
void Start(){ controller = this.GetComponent<ControllerPlayer>(); default_Speed_Run = GameAttribute.gameAttribute.speed; animationState = Run; }
private void Start() { useController = currentControllerType; characterController = gameObject.GetComponent<ControllerPlayer>(); boatController = gameObject.GetComponent<ControllerBoat>(); }