private void AbilityHandle() { switch (_abilityStatus) { case AbilityStatus.Ready: _showButton = true; _canActivate = true; break; case AbilityStatus.Active: ActivateAbility(); _abilityDuration -= Time.deltaTime; if (_abilityDuration < 0) { _abilityStatus = AbilityStatus.Charging; _abilityDuration = _abilityTimer; _canDeactivate = true; } break; case AbilityStatus.Charging: DeactivateAbility(); _abilityCoolDownDuration -= Time.deltaTime; if (_abilityCoolDownDuration < 0) { _abilityStatus = AbilityStatus.Ready; _abilityCoolDownDuration = _abilityCoolDownTimer; } break; } }
void Update() { if (currentStatus == AbilityStatus.Cooldown && Time.time > cooldownEnd) { currentStatus = AbilityStatus.Ready; } }
private int boostAmmount; //the bonus added, and the amount that should be subtracted when the boost ends void Start() { heroStats = GetComponent <HeroStats>(); currentStatus = AbilityStatus.Cooldown; cooldownEnd = Time.time + cooldownTime; heroBehaviorExecutor = GetComponent <BehaviourExecutor>(); }
void OnGUI() { var position = Camera.main.WorldToScreenPoint(gameObject.transform.position); GUI.contentColor = Color.white; GUI.backgroundColor = Color.blue; GUI.skin.button.fontSize = 8; switch (_abilityStatus) { case AbilityStatus.Ready: if (GUI.Button(new Rect(position.x, Screen.height - position.y - 30, 40, 20), _onGuiText)) { _showButton = false; _abilityStatus = AbilityStatus.Active; } break; case AbilityStatus.Active: int i = Mathf.RoundToInt(_abilityDuration); GUI.Label(new Rect(position.x, Screen.height - position.y - 30, 40, 20), i.ToString(), "box"); break; case AbilityStatus.Charging: int j = Mathf.RoundToInt(_abilityCoolDownDuration); GUI.Label(new Rect(position.x, Screen.height - position.y - 30, 40, 20), "cd: " + j.ToString(), "box"); break; } }
private bool CheckStatus(AbilityStatus status) { if (AbilityOverride) { return(ActiveAbility.OverrideProperties.Status == status); } return(GlobalProperties.Status == status); }
public void activateAbility() { //round up because we are good guy boostAmmount = (int)Math.Ceiling(heroStats.getAttack() * percentBoost); //add an effect heroBehaviorExecutor.addEffect(new BoostAttack(duration, boostAmmount, heroStats)); currentStatus = AbilityStatus.Cooldown; cooldownEnd = Time.time + cooldownTime; }
// Use this for initialization void Start() { sprintSlider = GameObject.Find("P" + playerID + "SprintSlider"); sprintSlider.GetComponent <Slider> ().value = sprintSlider.GetComponent <Slider> ().maxValue; bombImage = GameObject.Find("Canvas").transform.FindChild("P" + playerID + "UI").FindChild("P" + playerID + "BombImage").gameObject; bombImage.GetComponent <Image> ().color = Color.white; bombImage.SetActive(false); Diagnostics.DrawDebugOn = true; myBody = GetComponent <Rigidbody2D> (); animator = this.transform.GetChild(0).GetComponent <Animator> (); if (nametag == null) { nametag = transform.FindChild("Nametag").GetComponent <TextMesh> (); nametag.color = transform.GetChild(0).GetChild(0).GetComponent <SpriteRenderer> ().material.color; nametag.text = playerName; } footTransform = transform.FindChild("FootPosition"); nametagScale = new Vector3(nametag.transform.localScale.x, nametag.transform.localScale.y, nametag.transform.localScale.z); nametagMinScale = new Vector3(-nametag.transform.localScale.x, nametag.transform.localScale.y, nametag.transform.localScale.z); abs = this.transform.GetComponentInChildren <AbilityStatus> (); absScale = new Vector3(abs.transform.localScale.x, abs.transform.localScale.y, abs.transform.localScale.z); absMinScale = new Vector3(-abs.transform.localScale.x, abs.transform.localScale.y, abs.transform.localScale.z); scale = new Vector3(transform.localScale.x, transform.localScale.y, transform.localScale.z); minScale = new Vector3(-transform.localScale.x, transform.localScale.y, transform.localScale.z); sprintParticle = Resources.Load <GameObject> ("DustParticle"); sprintBar = this.transform.FindChild("SprintStatus").GetComponent <SpriteRenderer> (); sprintBar.color = playercolor; sprintScale = new Vector3(sprintBar.transform.localScale.x, sprintBar.transform.localScale.y, sprintBar.transform.localScale.z); sprintMinScale = new Vector3(-sprintBar.transform.localScale.x, sprintBar.transform.localScale.y, sprintBar.transform.localScale.z); //raycasting setup Transform raycast = transform.FindChild("Raycasts"); raycastObjects = new Transform[raycast.childCount]; for (int i = 0; i < raycast.childCount; ++i) { raycastObjects[i] = raycast.GetChild(i); } if (GlobalProperties.IS_NETWORKED) { //tell camera we have joined GameObject.FindObjectOfType <GameCamera> ().MyPlayerHasJoined(); } //this will be null forever if you are player controller player instead of AI AI = GetComponent <AIComponent> (); if (XBox == null) { LOCAL_SetPlayerNumber(playerID); } }
public bool Mode_TryActivate(int ModeID, int AbilityIndex, AbilityStatus status, float time = 0) { var mode = Mode_Get(ModeID); if (mode != null) { Pin_Mode = mode; return(Pin_Mode.TryActivate(AbilityIndex, status, time)); } return(false); }
protected override void Start() { base.Start(); _abilityStatus = AbilityStatus.Ready; //caching all the data to class's local data _abilityTimer = _abilityDuration; _abilityCoolDownTimer = _abilityCoolDownDuration; _cachedMovementSpeed = _defaultWorker.MovementSpeed; _cachedCapacity = _defaultWorker.Capacity; _cachedCollectRate = _defaultWorker.CollectRate; RandomAbility(); }
/// <summary> /// Called by the Mode Behaviour on Entering the Animation State /// Done this way to check for Modes that are on other Layers besides the Base Layer </summary> public void AnimationTagEnter(int animatorTagHash) { if (animatorTagHash != ModeTagHash) { return; // if we are not on this Tag then Skip the code } if (ActiveAbility != null) { Animal.IsPlayingMode = PlayingMode = true; //Pon a dormir el state Animal.CheckStateToModeSleep(true); OnEnterInvoke(); //Invoke the ON ENTER Event // ActiveAbility.IsPlayingAbility = true; //Set to the Ability that is playing the animation(s) AbilityStatus AMode = ActiveAbility.OverrideProp ? ActiveAbility.OverrideProperties.Status : GlobalProperties.Status; //Check if the Current Ability overrides the global properties float HoldByTime = ActiveAbility.OverrideProp ? ActiveAbility.OverrideProperties.HoldByTime : GlobalProperties.HoldByTime; int IntID = Int_ID.Loop; //That means the Ability is Loopable if (AMode == AbilityStatus.PlayOneTime) { IntID = Int_ID.OneTime; //That means the Ability is OneTime if (Animal.debugModes) { Debug.Log("Animation <b>Enter</b>. Mode: <b>" + Name + "</b>. Ability: <b>" + ActiveAbility.Name + "</b> PlayOneTime"); } } else if (AMode == AbilityStatus.HoldByTime) { Animal.StartCoroutine(Ability_By_Time(HoldByTime)); if (Animal.debugModes) { Debug.Log("Animation <b>Enter</b>. Mode: <b>" + Name + "</b>. Ability: <b>" + ActiveAbility.Name + "</b> HoldByTime"); } } //else if (AMode == AbilityStatus.HoldByInput) //{ // IntID = Int_ID.OneTime; //That means the Ability is OneTime // if (animal.debugModes) Debug.Log("AnimationTag Enter Mode: '" + ID.name + "' with Ability: '" + ActiveAbility.Name + "' Hold By Input '"); //} Animal.SetIntID(IntID); } }
/// <summary>Activate a mode on the Animal</summary> /// <param name="ModeID">ID of the Mode</param> /// <param name="AbilityIndex">Ability Index. If this value is -99 then the Mode will activate a random Ability</param> public virtual void Mode_Activate(int ModeID, int AbilityIndex, AbilityStatus status) { var mode = Mode_Get(ModeID); if (mode != null) { Pin_Mode = mode; var ability = Pin_Mode.GetAbility(AbilityIndex); if (ability != null) { ability.Properties.Status = status; //Change the Status of the ability } Pin_Mode.TryActivate(AbilityIndex); } else { Debug.LogWarning("You are trying to Activate a Mode but here's no Mode with the ID or is Disabled: " + ModeID); } }
public void SetABS(AbilityStatus abs) { this.abs = abs; }
public void activateAbility() { requisitionManager.addPoints(requisitionToAdd); currentStatus = AbilityStatus.Cooldown; cooldownEnd = Time.time + cooldownTime; }
void Start() { requisitionManager = GameObject.FindGameObjectWithTag("RequisitionManager").GetComponent <RequisitionManager>(); currentStatus = AbilityStatus.Cooldown; cooldownEnd = Time.time + cooldownTime; }