// Call this whenever the Player gets a new ability public void setupPanel(PlayerAbilityManager abilityManager) { int count = transform.childCount; for (int i = count - 1; i >= 0; i--) { Destroy(transform.GetChild(i).gameObject); } _playerAbilityManager = abilityManager; _abilities = new List <GameObject>(); GameObject abilityIcon = Resources.Load <GameObject>("Prefabs/AbilityIcon"); int numAbilities = _playerAbilityManager.abilities.Count; for (int i = 0; i < numAbilities; i++) { _abilities.Add(Instantiate(abilityIcon)); _abilities[i].name = _playerAbilityManager.abilities[i].abilityName; RectTransform rt = _abilities[i].GetComponent <RectTransform>(); rt.SetParent(GetComponent <RectTransform>()); rt.localPosition = new Vector2(50 * (i - numAbilities / 2), 34); rt.localScale = new Vector2(1, 1); } displayImages(); displayNames(); }
// Returns a PlayerStats object containing the extra stats that the player has. // The regular ObjectStats should be in 'stats' already. private static void LoadPlayerStats(PlayerStats stats, GameObject player, Rigidbody2D rb) { PlayerAbilityManager abilityManager = player.GetComponent <PlayerAbilityManager>(); if (abilityManager != null) { for (int i = 0; i < stats.enabledAbilities.Count; ++i) { abilityManager.enableAbility(stats.enabledAbilities[i]); Debug.Log("Player loading enabled abilities"); } } PlayerHealth plHealth = player.GetComponent <PlayerHealth>(); // Only load position, rotation and health if the scene of the same was same as the current one and // the scene where a save was previously loaded was the current one. if (stats.sceneName == game.scene && game.previouslyLoadedSaveScene == game.scene) { // Only load position and health if same level. rb.position = new Vector3(stats.posX, stats.posY, stats.posZ); rb.rotation = stats.rotZ; if (plHealth != null && stats.health > 0) // safety check { plHealth.setHealth(stats.health); } } }
// Use this for initialization void Start() { NetworkAnimator netAnimator = GetComponent <NetworkAnimator>(); for (int i = 0; i < netAnimator.animator.parameterCount; i++) { netAnimator.SetParameterAutoSend(i, true); } ramArea = transform.GetChild(2).gameObject; if (!this.isLocalPlayer) { return; } // Set custom attributes for class: PlayerEffects pe = GetComponent <PlayerEffects>(); pe.CmdSetAttributes(1.5f, 1.0f, 1.0f, 0.8f); // Add abilities to class: PlayerAbilityManager abilityManager = GetComponent <PlayerAbilityManager>(); SpeedBomb sp = gameObject.AddComponent <SpeedBomb>(); Stomp stomp = gameObject.AddComponent <Stomp>(); stomp.init(); sp.init(30, 4); abilityManager.abilities.Add(sp); abilityManager.abilities.Add(stomp); GameObject.Find("AbilityPanel").GetComponent <AbilityPanel>().setupPanel(abilityManager); this._playerController = GetComponent <PlayerController>(); }
// Use this for initialization void Start() { this._animator = GetComponent<Animator>(); NetworkAnimator netAnimator = GetComponent<NetworkAnimator>(); for (int i = 0; i < netAnimator.animator.parameterCount; i++) netAnimator.SetParameterAutoSend(i, true); if (!this.isLocalPlayer) return; this._pc = GetComponent<PlayerController>(); // Set custom attributes for class: PlayerEffects pe = GetComponent<PlayerEffects>(); pe.CmdSetAttributes(0.7f, 0.8f, 1.2f, 1.0f); // Add abilities to class: this._am = GetComponent<PlayerAbilityManager>(); var ds = gameObject.AddComponent<DustStorm>(); var dt = gameObject.AddComponent<DustTornadoAbility>(); ds.init(); dt.init(); this._am.abilities.Add(ds); this._am.abilities.Add(dt); GameObject.Find("AbilityPanel").GetComponent<AbilityPanel>().setupPanel(this._am); this._pecking = false; }
private IEnumerator checkIfPlayerHasAbility() { // Wait for a couple frames. yield return(null); yield return(null); GameObject pl = GameObject.FindGameObjectWithTag("Player"); if (pl == null) { Debug.LogError("AbilityTrigger " + gameObject.name + " can't find the Player GameObject (no GameObject found with the tag 'Player'."); } else { PlayerAbilityManager am = pl.GetComponent <PlayerAbilityManager>(); if (am == null) { Debug.LogError("AbilityTrigger " + gameObject.name + " can't get 'PlayerAbilityManager' component on the Player GameObject."); } else { // set this to disabled if the player has this ability already if (am.getEnabledAbilities().Contains(abilityName)) { gameObject.SetActive(false); } } } }
void Start() { if (SceneManager.GetActiveScene().name == "Lobby") { return; } NetworkAnimator netAnimator = GetComponent <NetworkAnimator>(); for (int i = 0; i < netAnimator.animator.parameterCount; i++) { netAnimator.SetParameterAutoSend(i, true); } this._poopCameraPos = transform.GetChild(2); bunnyPoop = Resources.Load <GameObject>("Prefabs/poop"); playerInfo = GetComponent <PlayerInformation>(); if (!this.isLocalPlayer) { return; } _controller = GetComponent <CharacterController>(); _timer = 0; _fireRate = 0.2f; // Set custom attributes for class: PlayerEffects pe = GetComponent <PlayerEffects>(); pe.CmdSetAttributes(1.0f, 1.0f, 1.0f, 1.5f); // Add abilities to class: PlayerAbilityManager abilityManager = GetComponent <PlayerAbilityManager>(); SuperJump sj = gameObject.AddComponent <SuperJump>(); sj.init(10); GrenadePoop gp = gameObject.AddComponent <GrenadePoop>(); gp.init(); abilityManager.abilities.Add(sj); abilityManager.abilities.Add(gp); GameObject.Find("AbilityPanel").GetComponent <AbilityPanel>().setupPanel(abilityManager); this._alertOverlay = GameObject.Find("Alert").GetComponent <Image>(); this._alertSound = Resources.Load <AudioClip>("Audio/BunnyAlert"); CmdGetEnemies(); this._playerController = GetComponent <PlayerController>(); this._alertReady = false; StartCoroutine(alertCooldown(2.0f)); }
//Internal Methods protected override IEnumerator ModifierEffect() { player = FindObjectOfType <PlayerAbilityManager>(); player.SetRemovedCooldown(true); float timer = 0f; while (timer <= modifierDuration) { timer += Time.deltaTime / Time.timeScale; yield return(null); } player.SetRemovedCooldown(false); ExpireModifier(); }
void OnTriggerEnter(Collider col) { if(col.tag == VariableScript.playersTag){ pam = col.GetComponent<PlayerAbilityManager>(); psh = col.GetComponent<PlayerShoot>(); pstat = col.GetComponent<PlayerStats>(); if(Time.time >= ready && pam != null){ int index = pam.AddAbility(gameObject); // Adds the ability and returns the index of the slot added into (else returns -1) if(index != -1){ gameObject.SetActive(false); SetUp(index); } } } }
// Returns a PlayerStats object containing the extra stats that the player has. // The regular ObjectStats should be in 'stats' already. private static PlayerStats SavePlayerStats(ObjectStats stats, GameObject player, string scene) { PlayerStats plStats = new PlayerStats(stats); PlayerAbilityManager abilityManager = player.GetComponent <PlayerAbilityManager>(); if (abilityManager != null) { plStats.enabledAbilities = abilityManager.getEnabledAbilities(); } PlayerHealth plHealth = player.GetComponent <PlayerHealth>(); if (plHealth != null) { plStats.health = plHealth.getHealth(); } plStats.sceneName = scene; return(plStats); }
void Start() { CorrectRenderingMode(); // Calling this here to fix the rendering order of the model, because materials have rendering mode fade if (!this.isLocalPlayer) { return; } this._cameraTransform = Camera.main.transform; this.controller = this.GetComponent <CharacterController>(); this.playerEffects = this.GetComponent <PlayerEffects>(); this._abilityManager = this.GetComponent <PlayerAbilityManager>(); this._playerHealth = this.GetComponent <PlayerHealth>(); this.airControlPercent = 1; spawn(); }
// Use this for initialization void Start() { NetworkAnimator netAnimator = GetComponent <NetworkAnimator>(); for (int i = 0; i < netAnimator.animator.parameterCount; i++) { netAnimator.SetParameterAutoSend(i, true); } biteArea = transform.GetChild(2).gameObject; if (!this.isLocalPlayer) { return; } // Set custom attributes for class: PlayerEffects pe = GetComponent <PlayerEffects>(); pe.CmdSetAttributes(1.2f, 1.2f, 1.2f, 0.8f); // Add abilities to class: PlayerAbilityManager abilityManager = GetComponent <PlayerAbilityManager>(); Sprint sp = gameObject.AddComponent <Sprint>(); sp.init(50, 1); abilityManager.abilities.Add(sp); Stealth st = gameObject.AddComponent <Stealth>(); st.init(1, 0); abilityManager.abilities.Add(st); GameObject.Find("AbilityPanel").GetComponent <AbilityPanel>().setupPanel(abilityManager); CmdApplySmell(); this._playerController = GetComponent <PlayerController>(); }
void Start() { ps = VariableScript.scrPlayerScript1; phs = VariableScript.scrPlayerHealthScript1; pe = VariableScript.scrPlayerExperience1; pam = ps.GetComponent<PlayerAbilityManager>(); hpStyle.normal.textColor = Color.white; hpStyle.fontSize = 40; attributeStyle.normal.textColor = Color.white; attributeStyle.fontSize = 20; statStyle.normal.textColor = Color.white; statStyle.fontSize = 25; }
private void Start() { ps = GetComponent<PlayerScript>(); pam = GetComponent<PlayerAbilityManager>(); pstat = GetComponent<PlayerStats>(); projectilePrefabsArray = new GameObject[][]{ projectilePrefabs0, projectilePrefabs1, projectilePrefabs2, projectilePrefabs3 }; }
// Use this for initialization void Start() { current_animationID = 0; Sprite[] sprites = Resources.LoadAll <Sprite>("Art/CharacterSpriteSheet"); animationController = this.GetComponent <AnimationController>(); animationController.Animations = new AnimationController.SpriteAnimation[6]; animationController.Animations[0] = new AnimationController.SpriteAnimation(); animationController.Animations[0].name = "Idle"; animationController.Animations[0].sprites = new Sprite[4]; animationController.Animations[0].sprites[0] = sprites[45]; animationController.Animations[0].sprites[1] = sprites[46]; animationController.Animations[0].sprites[2] = sprites[47]; animationController.Animations[0].sprites[3] = sprites[48]; animationController.Animations[1] = new AnimationController.SpriteAnimation(); animationController.Animations[1].name = "Left_Walk"; animationController.Animations[1].sprites = new Sprite[7]; animationController.Animations[1].sprites[0] = sprites[0]; animationController.Animations[1].sprites[1] = sprites[1]; animationController.Animations[1].sprites[2] = sprites[2]; animationController.Animations[1].sprites[3] = sprites[3]; animationController.Animations[1].sprites[4] = sprites[4]; animationController.Animations[1].sprites[5] = sprites[5]; animationController.Animations[1].sprites[6] = sprites[6]; animationController.Animations[2] = new AnimationController.SpriteAnimation(); animationController.Animations[2].name = "Right_Walk"; animationController.Animations[2].sprites = new Sprite[7]; animationController.Animations[2].sprites[0] = sprites[49]; animationController.Animations[2].sprites[1] = sprites[50]; animationController.Animations[2].sprites[2] = sprites[51]; animationController.Animations[2].sprites[3] = sprites[52]; animationController.Animations[2].sprites[4] = sprites[53]; animationController.Animations[2].sprites[5] = sprites[54]; animationController.Animations[2].sprites[6] = sprites[55]; animationController.Animations[3] = new AnimationController.SpriteAnimation(); animationController.Animations[3].name = "Up_Walk"; animationController.Animations[3].sprites = new Sprite[7]; animationController.Animations[3].sprites[0] = sprites[37]; animationController.Animations[3].sprites[1] = sprites[38]; animationController.Animations[3].sprites[2] = sprites[39]; animationController.Animations[3].sprites[3] = sprites[40]; animationController.Animations[3].sprites[4] = sprites[41]; animationController.Animations[3].sprites[5] = sprites[42]; animationController.Animations[3].sprites[6] = sprites[43]; animationController.Animations[4] = new AnimationController.SpriteAnimation(); animationController.Animations[4].name = "Down_Walk"; animationController.Animations[4].sprites = new Sprite[7]; animationController.Animations[4].sprites[0] = sprites[29]; animationController.Animations[4].sprites[1] = sprites[30]; animationController.Animations[4].sprites[2] = sprites[31]; animationController.Animations[4].sprites[3] = sprites[32]; animationController.Animations[4].sprites[4] = sprites[33]; animationController.Animations[4].sprites[5] = sprites[34]; animationController.Animations[4].sprites[6] = sprites[35]; animationController.Animations[5] = new AnimationController.SpriteAnimation(); animationController.Animations[5].name = "Down_Attack"; animationController.Animations[5].sprites = new Sprite[5]; animationController.Animations[5].sprites[0] = sprites[23]; animationController.Animations[5].sprites[1] = sprites[24]; animationController.Animations[5].sprites[2] = sprites[25]; animationController.Animations[5].sprites[3] = sprites[26]; animationController.Animations[5].sprites[4] = sprites[27]; myBody = GetComponent <Rigidbody2D>(); hand = transform.Find("PlayerHand"); currentHandAngle = 0; stats = new CharacterStats(5, 5, 5, 5, 5, 5, 100); level = getLevel(); moveSpeed = stats.GetStat(Stat.StatType.Speed).GetFinalStatValue(); abilityManager = GetComponent <PlayerAbilityManager>(); busy = false; }