// Use this for initialization void Start() { GameObject thePlayer = GameObject.FindGameObjectWithTag("Player"); thePlayerController = thePlayer.GetComponent<PlayerController>(); theAbilities = thePlayer.GetComponentInChildren<PlayerAbilities>(); healthBar = GameObject.FindGameObjectWithTag("healthBar").GetComponent<Slider>(); healthValue = healthBar.GetComponentInChildren<Text>(); theKing = GameObject.FindGameObjectWithTag("theKing").GetComponent<KingControl>(); bossHealthBar = GameObject.FindGameObjectWithTag("bossHealthBar").GetComponent<Slider>(); bossHealthValue = bossHealthBar.GetComponentInChildren<Text>(); ability1 = GameObject.FindGameObjectWithTag("ability1").GetComponent<Image>(); cdSlider1 = ability1.GetComponentInChildren<Slider>(); cdText1 = cdSlider1.GetComponentInChildren<Text>(); ability2 = GameObject.FindGameObjectWithTag("ability2").GetComponent<Image>(); cdSlider2 = ability2.GetComponentInChildren<Slider>(); cdText2 = cdSlider2.GetComponentInChildren<Text>(); ability3 = GameObject.FindGameObjectWithTag("ability3").GetComponent<Image>(); cdSlider3 = ability3.GetComponentInChildren<Slider>(); cdText3 = cdSlider3.GetComponentInChildren<Text>(); powerUpPanel = GameObject.FindGameObjectWithTag("powerUpPanel").GetComponent<RectTransform>(); }
/// <summary> /// Searches the key from the dictionary and then call it. /// </summary> /// <param name="key">Player Ability Type</param> /// <param name="r">Player RigidBody2D</param> public static void CallEvent(PlayerAbilities key, Rigidbody2D r) { if (abilityDict.ContainsKey(key)) { abilityDict[key].Invoke(r); } }
public override void Initialize(PlayerAbilities pa) { PoolManager.instance.AddPoolSize(gunPrefab, numGuns, true); PoolManager.instance.AddPoolSize(bulletPrefab, (int)Mathf.Ceil(1 / shootingCooldown) * numGuns * 2, true); spawnedGuns = new List <GameObject>(); base.Initialize(pa); }
private void OnTriggerEnter2D(Collider2D otherObj) { if (otherObj.name == "Player(Clone)" || otherObj.name == "Player_1(Clone)" || otherObj.name == "Player_2(Clone)") { PlayerAbilities playerAbilities = otherObj.GetComponent <PlayerAbilities>(); //gets player script access if (playerAbilities != null) //ensure player was the one that collided with object { soundFX.PowerUpSound(); switch (powerUpID) { case 0: playerAbilities.ActivateTripleShotPowerUp(); break; case 1: playerAbilities.ActivateSpeedBoostPowerUp(); break; case 2: playerAbilities.isShieldActive = true; playerAbilities.ActivateShield(); break; default: print("no powerup ID found"); break; } Destroy(gameObject); } } }
public void HandleDeath(BDice dice) { UnregisterAbility(dice); if (dice.TargetType == ETargetType.Ally) { ActivePlayerModels.Remove(dice); PlayerAbilities.Remove(dice); } else if (dice.TargetType == ETargetType.Enemy) { ActiveEnemyModels.Remove(dice); EnemyAbilities.Remove(dice); } if (ActivePlayerModels.Count == 0) { IsGameOver = true; MenuManager.Instance.DisplayEndGameMessage("You Lost"); } else if (ActiveEnemyModels.Count == 0) { IsGameOver = true; MenuManager.Instance.DisplayEndGameMessage("You Won!"); } }
private void PlayerInit() { if (!rigid) { rigid = GetComponent <Rigidbody>(); } if (!invComponent) { invComponent = GetComponent <InventoryComponent> (); } if (!abilities) { abilities = GetComponent <PlayerAbilities> (); } if (!energy) { energy = GetComponent <PlayerEnergy> (); } if (!pointLight) { pointLight = GetComponent <Light> (); } if (!sound) { sound = GetComponent <PlayerSound> (); } if (!particles) { particles = GetComponent <PlayerParticles> (); } }
public override void UseAbility() { Debug.Log("Using single target heal"); if (healSelf) { GameObject go = Instantiate(healParticleSystem, playerAbilities.transform.position, Quaternion.identity); Destroy(go, abilityLifetime); Debug.Log("Healing self"); go.transform.SetParent(playerAbilities.transform); playerAbilities.StartCoroutine(playerAbilities.ApplyHealing(healPerCycle, numberOfHealCycles, betweenCycles)); } else { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(ray, out hit)) { Debug.Log("Found raycast target called : " + hit.collider.name); PlayerAbilities p = hit.collider.GetComponent <PlayerAbilities>(); if (p != null && p.GetComponent <Team>().team == teamWhoCast) { Debug.Log("Applied healing affect"); p.StartCoroutine(p.ApplyHealing(healPerCycle, numberOfHealCycles, betweenCycles)); GameObject go = Instantiate(healParticleSystem, p.transform.position, Quaternion.identity); Destroy(go, abilityLifetime); go.transform.SetParent(p.transform); } } } }
// Start is called before the first frame update void Start() { playerAbilities = GetComponent <PlayerAbilities>(); playerAbilities.OnSpellCrafted += PlayerAbilities_OnSpellCrafted; SetCooldowns(); playerController = GetComponent <PlayerController>(); }
// Use this for initialization void Start() { GameObject thePlayer = GameObject.FindGameObjectWithTag("Player"); thePlayerController = thePlayer.GetComponent <PlayerController>(); theAbilities = thePlayer.GetComponentInChildren <PlayerAbilities>(); healthBar = GameObject.FindGameObjectWithTag("healthBar").GetComponent <Slider>(); healthValue = healthBar.GetComponentInChildren <Text>(); theKing = GameObject.FindGameObjectWithTag("theKing").GetComponent <KingControl>(); bossHealthBar = GameObject.FindGameObjectWithTag("bossHealthBar").GetComponent <Slider>(); bossHealthValue = bossHealthBar.GetComponentInChildren <Text>(); ability1 = GameObject.FindGameObjectWithTag("ability1").GetComponent <Image>(); cdSlider1 = ability1.GetComponentInChildren <Slider>(); cdText1 = cdSlider1.GetComponentInChildren <Text>(); ability2 = GameObject.FindGameObjectWithTag("ability2").GetComponent <Image>(); cdSlider2 = ability2.GetComponentInChildren <Slider>(); cdText2 = cdSlider2.GetComponentInChildren <Text>(); ability3 = GameObject.FindGameObjectWithTag("ability3").GetComponent <Image>(); cdSlider3 = ability3.GetComponentInChildren <Slider>(); cdText3 = cdSlider3.GetComponentInChildren <Text>(); powerUpPanel = GameObject.FindGameObjectWithTag("powerUpPanel").GetComponent <RectTransform>(); }
void OnCollisionEnter(Collision coll) { PlayerAbilities player = coll.gameObject.GetComponent <PlayerAbilities>(); rb.isKinematic = true; gameObject.GetComponent <BoxCollider>().isTrigger = true; Invoke("Freeze", 0.005f); if (player != null) { transform.SetParent(player.transform); if (teamWhoShot == coll.gameObject.GetComponent <Team>().team) { // Friendly Fire Debug.Log("Hit friendly"); } else { player.DealDamage(damageToDeal); Debug.Log("Dealing " + damageToDeal + " to " + player.name); } } else { // Hit something that is not the player } }
private void Awake() { idleState = new IdleState(this); moveState = new MoveState(this); attackState = new AttackState(this); castState = new CastState(this); fleeState = new FleeState(this); defendState = new DefendState(this); anim = GetComponent <Animator>(); walkSpeed = 1.0f; navMeshAgent = GetComponent <NavMeshAgent>(); navSpeedDefault = navMeshAgent.speed; eyes = transform.FindChild("Eyes"); sightCollider = GetComponent <SphereCollider>(); tm = GameObject.FindWithTag("TeamManager").GetComponent <TeamManager>(); ah = GameObject.FindWithTag("AbilityHelper").GetComponent <AbilityHelper>(); //this is a mess. These are "shared" variables between co-op ai and player script player = GetComponent <Player>(); animController = player.animController; abilities = player.abilities; attributes = player.attributes; watchedEnemies = player.watchedEnemies; visibleEnemies = player.visibleEnemies; }
/* * slots[0] = head armor * slots[1] = body armor * slots[2] = leg armor * slots[3] = feet armor */ // Start is called before the first frame update void Awake() { player = GameObject.FindGameObjectWithTag("Player"); health = player.GetComponent <PlayerHealth>(); movement = player.GetComponent <PlayerMovement>(); damage = player.GetComponent <PlayerAbilities>(); }
public void UseAbility(Ability ability, PlayerAbilities player, string t) { ability.playerAbilities = player; ability.teamWhoCast = t; ability.UseAbility(); ability.lastUsedTime = Time.time + ability.cooldownTime; }
//randomly select and display three abilities to choose from public void DisplayNewAbility() { GameObject display = Instantiate(newAbilitySelect, new Vector3(0, 0), Quaternion.identity, GameObject.Find("HUDCanvas").transform); abilityManager abilityManager = GameObject.Find("AbilityManager").GetComponent <abilityManager>(); List <GameObject> choices = abilityManager.newAbility(); for (int i = 0; i < 3; i++) { GameObject choice = Instantiate(choices[i], new Vector3(0, i * 3, 0), Quaternion.identity); NewAbilitySelect select = display.GetComponent <NewAbilitySelect>(); select.AddChoice(choice); PlayerAbilities[] playerAbilitiesList = GetComponentsInChildren <PlayerAbilities>(true); PlayerAbilities playerAbilities = GetComponentsInChildren <PlayerAbilities>(true)[playerAbilitiesList.Length - 1]; select.GetComponentsInChildren <Button>()[i].onClick.AddListener(delegate { playerAbilities.LearnAbility(choice); choice.transform.parent = playerAbilities.transform; //create new map and load it GameObject.Find("GameManager").GetComponent <MapManager>().CreateMap(); GameObject.Find("GameManager").GetComponentInChildren <PlayerMovement>(true).Init(); SceneManager.LoadScene("Map"); }); } }
void CheckChoice(GameObject abilitypick, PlayerAbilities playerabilities){ if (abilitypick.tag == "Weapon" && weaponpicks < 1) { if (abilitypick.name == "flamethrower") { playerabilities.fire = true; } if (abilitypick.name == "boomerang") { playerabilities.boomerang = true; } if (abilitypick.name == "sniper") { playerabilities.sniper = true; } if (abilitypick.name == "machinegun") { playerabilities.machinegun = true; } } if (abilitypick.tag == "Ability" && abilitypicks == 0) { if (abilitypick.name == "mine") { playerabilities.ability1 = "mine";; } } if (abilitypick.tag == "Ability" && abilitypicks == 1) { if (abilitypick.name == "mine") { playerabilities.ability2 = "mine";; } } }
/// <summary> /// initialize conponents of the player here /// </summary> void Start() { ridgidbodyPlayer = gameObject.GetComponent <Rigidbody2D>(); transform.localScale = new Vector3(1, 1, 1); facingRight = true; defaultCollider = transform.Find("Default Collider").gameObject; crouchCollider = transform.Find("Crouch Collider").gameObject; crouchCollider.SetActive(false); aimingSpeed = 90f; worldSize = Camera.main.ScreenToWorldPoint(new Vector3(Screen.width, 0.0f, 0.0f)); worldHalfSize = this.GetComponentInChildren <Renderer>().bounds.size.x / 2; playerAbilities = gameObject.GetComponent <PlayerAbilities>(); int scene = SceneManager.GetActiveScene().buildIndex; if (scene == 4) { blackHoleCheckPoint = GameObject.Find("StartPoint").GetComponent <Transform>(); } //Debug.Log(blackHoleCheckPoint); //BallSpawnPoint = transform.Find("BallSpawnPoint"); }
void GetComponents() { myAgent = GetComponent <NavMeshAgent>(); player = GameObject.FindObjectOfType <PlayerMovement>(); playerAbilities = player.GetComponent <PlayerAbilities>(); collider = GetComponent <CapsuleCollider> (); }
private void Awake() { player = GameObject.FindGameObjectWithTag("Player"); playerAbilities = player.GetComponent <PlayerAbilities>(); playerExperience = player.GetComponent <PlayerExperience>(); db = GameObject.FindGameObjectWithTag("ItemDB").GetComponent <ItemDatabase>(); }
public void RegisterAbility(BDice dice) { //if (dice.UpSide.Ability.TargetType != ETargetType.None) if (dice.TargetType == ETargetType.Ally) { if (PlayerAbilities.ContainsKey(dice)) { UnregisterAbility(dice); } PlayerAbilities.Add(dice, dice.UpSide.Ability); } else { if (EnemyAbilities.ContainsKey(dice)) { UnregisterAbility(dice); } EnemyAbilities.Add(dice, dice.UpSide.Ability); } if (OnAbilityRegister != null) { OnAbilityRegister(dice); } // TODO: add check to see if all abilities do not have the target type of None, otherwise the turn would end if (TurnManager.Instance.IsPlayersTurn) { if (PlayerAbilities.Count == ActivePlayerModels.Count) { var count = 0; foreach (var d in ActivePlayerModels) { if (d.UpSide != null && d.UpSide.Ability.TargetType == ETargetType.None) { count++; } } if (count == ActivePlayerModels.Count) { TurnManager.Instance.EndTurn(); } } //bool isAllEmpty = true; //bool isMissingAny = false; //foreach (var d in PlayersModels) // if (!isAllEmpty || isMissingAny) // break; // else if (d.UpSide != null && d.UpSide.Ability.TargetType != ETargetType.None) // isAllEmpty = false; // else if (d.UpSide == null) // isMissingAny = true; //if(isAllEmpty & !isMissingAny) TurnManager.Instance.EndTurn(); } }
protected override void customStart() { movementSpeed = 6f; maxHP = 20f; playerAbilities = transform.GetChild(1).GetComponent <PlayerAbilities>(); cameraControl = Camera.main.GetComponent <CameraControl>(); cameraControl.setTarget(gameObject.transform); }
void Start() { diaManager = FindObjectOfType <DialogueManager>(); P1 = GameObject.Find("Player 1").GetComponent <PlayerAbilities>(); P2 = GameObject.Find("Player 2").GetComponent <PlayerAbilities>(); camera = GameObject.FindGameObjectWithTag("MainCamera"); }
void Start() { playerAbilities = GameObject.FindGameObjectWithTag("PlayerAbilities").GetComponent <PlayerAbilities>(); Vector3 willBeAt = playerTransform.position + offset; willBeAt.z = transform.position.z; Vector3 lerpPos = Vector3.Lerp(transform.position, willBeAt, velocity * Time.deltaTime); transform.position = lerpPos; }
// Use this for initialization void Awake() { _characterController = GetComponent <CharacterController>(); _animator = GetComponent <Animator>(); abilities = GetComponent <PlayerAbilities>(); _stateMan = GetComponent <PlayerStateManager>(); }
/// <summary> /// Gets the cooldown of the active ability. /// </summary> /// <param name="key">Active Ability</param> public static float GetCooldown(PlayerAbilities key) { if (abilityDict.ContainsKey(key)) { return(abilityCooldown[key]); } return(0); }
private void Awake() { rect = GetComponent <RectTransform>(); stateMan = player.GetComponent <PlayerStateManager>(); abilities = player.GetComponent <PlayerAbilities>(); equipMan = player.GetComponent <EquipmentManager>(); plAimer = player.GetComponent <PlayerAimer>(); shootSys = player.GetComponent <PlayerShootingSystem>(); }
public void Inject(PlayerUnitDI di) { PlayerAbilities abilities = di.abilities; movement = abilities.movement; jump = abilities.jump; wallSlide = abilities.wallSlide; physics = di.physics; }
public override void EndTurn() { //unhighlight me //GetComponent<SpriteRenderer>().color = Color.white; //remove my ability buttons PlayerAbilities abilities = GetComponent <PlayerAbilities>(); abilities.Hide(); }
public void findObjects() { player = GameObject.FindGameObjectWithTag("Player"); abilities = player.GetComponent <PlayerAbilities>(); health = player.GetComponent <PlayerHealth>(); exp = player.GetComponent <PlayerExperience>(); equip = player.GetComponent <PlayerEquip>(); movement = player.GetComponent <PlayerMovement>(); }
public PlayerEntity(Difficulty difficulty) { Inventory = new InventoryWindow(); for (int i = 0; i < Inventory.Length; i++) { Inventory[i] = ItemStack.EmptyStack; } SelectedSlot = InventoryWindow.HotbarIndex; bedUseTimer = new Timer(state => { if (BedTimerExpired != null) { BedTimerExpired(this, null); } }); BedPosition = -Vector3.One; Health = 20; Food = 20; Abilities = new PlayerAbilities(this); ItemInMouse = ItemStack.EmptyStack; Difficulty = difficulty; TerrainCollision += OnTerrainCollision; FoodTickTimer = new Timer(discarded => { if (Food > 17 && Health < 20 && Health != 0) // TODO: HealthMax constant? { Health++; } if (Food == 0 && GameMode != GameMode.Creative) { switch (Difficulty) { case Difficulty.Hard: if (Health > 0) { Health--; } break; case Difficulty.Normal: if (Health > 1) { Health--; } break; default: if (Health > 10) { Health--; } break; } } }, null, 80 * Level.TickLength, 80 * Level.TickLength); }
// Use this for initialization void Start() { ammoInClip = clipSize; shootIntervalProgress = shootInterval + 1; reloadProgress = reloadTime + 1; playerInv = this.gameObject.transform.parent.parent.GetComponentInChildren <Inventory>(); playerAbilities = GetComponentInParent <PlayerAbilities>(); playerAttributes = GetComponentInParent <PlayerAttributes>(); audioSource = gameObject.GetComponent <AudioSource>(); }
private void InvokeAbility(PlayerAbilities ability) { //add score GameplayScript.current.AddScore(scores["ability"]); float cooldown = AbilityProcessor.GetCooldown(ability); AbilityProcessor.CallEvent(ability, rigid); coro = StartCoroutine(AbilityCooldown(cooldown)); }
void Awake() { player = GameObject.FindGameObjectWithTag("Player"); exp = player.GetComponent <PlayerExperience>(); playerAbilities = player.GetComponent <PlayerAbilities>(); abilityImage = this.gameObject.GetComponent <Image>(); toolTip = GameObject.Find("SkillToolTipText").GetComponent <SkillTooltip>(); toolTipObject = GameObject.Find("SkillToolTip"); bar = GameObject.Find("AbilityBarPanel").GetComponent <UIAbilityBar>(); }
// Use this for initialization void Start () { if (playernumber == 1) { xaxiscontrol = "Horizontal"; yaxiscontrol = "Vertical"; readybutton = "StartButton"; pickbutton = "PickButton"; backbutton = "BackButton"; playercolor = Color.blue; playerabilities = GameObject.FindGameObjectWithTag("Player1Info").GetComponent<PlayerAbilities>(); } if (playernumber == 2) { xaxiscontrol = "Horizontal2"; yaxiscontrol = "Vertical2"; readybutton = "StartButton2"; pickbutton = "PickButton2"; backbutton = "BackButton2"; playercolor = Color.red; playerabilities = GameObject.FindGameObjectWithTag("Player2Info").GetComponent<PlayerAbilities>(); } if (playernumber == 1) { xaxiscontrol = "Horizontal"; yaxiscontrol = "Vertical"; ability1control = "FirstAbility"; } if (playernumber == 1) { xaxiscontrol = "Horizontal"; yaxiscontrol = "Vertical"; ability1control = "FirstAbility"; } for (int i = 0; i < 2; i++) { for (int j = 0; j < 4; j++) { if(index < 5){ print (index); abilities[j, i] = possibleabilities[index]; index++; } } } currentselection = abilities[(int)currentabilityrow, (int)currentabilitycolumn]; currentselection.GetComponent<SpriteRenderer>().color = Color.red; }
public PlayerEntity(Difficulty difficulty) { Inventory = new InventoryWindow(); for (int i = 0; i < Inventory.Length; i++) Inventory[i] = ItemStack.EmptyStack; SelectedSlot = InventoryWindow.HotbarIndex; bedUseTimer = new Timer(state => { if (BedTimerExpired != null) BedTimerExpired(this, null); }); BedPosition = -Vector3.One; Health = 20; Food = 20; Abilities = new PlayerAbilities(this); ItemInMouse = ItemStack.EmptyStack; Difficulty = difficulty; TerrainCollision += OnTerrainCollision; FoodTickTimer = new Timer(discarded => { if (Food > 17 && Health < 20 && Health != 0) // TODO: HealthMax constant? Health++; if (Food == 0 && GameMode != GameMode.Creative) { switch (Difficulty) { case Difficulty.Hard: if (Health > 0) Health--; break; case Difficulty.Normal: if (Health > 1) Health--; break; default: if (Health > 10) Health--; break; } } }, null, 80 * Level.TickLength, 80 * Level.TickLength); }
void Start() { pData = GameObject.FindGameObjectWithTag("Player").GetComponent<PlayerData>(); pAbilities = GameObject.FindGameObjectWithTag("Player").GetComponent<PlayerAbilities>(); text = GetComponent<Text>(); }