public List <IA_Action> ComputeIAActions(HashSet <Tile> moveRangeTiles) { //Debug.Log ("moveRangeTiles.count = " + moveRangeTiles.Count); List <IA_Action> IAActionList = new List <IA_Action> (); foreach (Tile currentTile in moveRangeTiles) { IA_Action currentIA_Action = new IA_Action(currentTile, m_SpaceObjectSelected); foreach (Weapon currentWeapon in m_SpaceObjectSelected.GetWeaponController().GetEquipments()) { //Debug.Log("current tile = " + currentTile.gameObject.name); HashSet <Tile> attackRangeTiles = currentWeapon.ComputeAttackRange(currentTile); /*Debug.Log ("attackRangeTiles.count = " + attackRangeTiles.Count); * if(attackRangeTiles.Contains(GameObject.Find("Tile(2;6)").GetComponent<Tile>())) * Debug.Log ("OK");*/ List <SpaceObject> targets = currentWeapon.ComputeTargetInRange(attackRangeTiles); //Debug.Log ("targets.count = " + targets.Count); WeaponAction currentWeaponAction = ComputeWeaponAction(targets, currentWeapon); //Debug.Log("currentWeaponAction target = " + currentWeaponAction.m_Target.gameObject.name + " / current score = " + currentWeaponAction.m_Score); currentIA_Action.AddWeaponAction(currentWeaponAction); } //Debug.Log("intersection = " + currentIA_Action.m_WeaponIntersection); if (currentIA_Action.m_WeaponActionNumber > 0) { //Debug.Log("currentWeaponAction target = " + currentIA_Action.m_WeaponActions.m_Target.gameObject.name + " / current score = " + currentWeaponAction.m_Score); currentIA_Action.ComputeBestCombination(); IAActionList.Add(currentIA_Action); } } //Debug.Log("IAActionList.count = " + IAActionList.Count); return(IAActionList); }
public virtual void Initialize() { /** * the actionKey should be passed down from an Input class or something * It's quite awkward to do it here though tbh, so what the f**k should i do? * (╯°□°)╯︵ ┻━┻ * * An alternative would be creating WeaponActions outside and just passing them down * Which would be cleaner here but would sometimes require longer names like LaserPreChargeGunAAction * Although that wouldn't happen most of the time tbh, more so it wouldn't be specific to a gun but who the f**k knows **/ // TODO: Move the WeaponActions outside and just add them without creating them here WeaponAction reloadAction = new WeaponAction(); reloadAction.actionKey = KeyCode.R; reloadAction.actionEvent += new WeaponActionEvent(Reload); WeaponAction ShootAction = new WeaponAction(); ShootAction.actionKey = KeyCode.Mouse0; ShootAction.actionEvent += new WeaponActionEvent(Shoot); WeaponActions.Add(reloadAction); WeaponActions.Add(ShootAction); Debug.Log("Weapon: " + this.GetType().Name + " is Initialized"); }
//Function called from DisplayActionTypes to loop through our action buttons and display the actions given private void UpdateActionButtons(List <Action> actionsToShow_) { //Looping through all of the action buttons in our list for (int b = 0; b < this.actionButtons.Count; ++b) { //If there are still actions to display, we display them if (b < actionsToShow_.Count) { //Checking to see if the current action is a weapon action if (this.actionButtons[b].GetType() == typeof(WeaponAction)) { WeaponAction wpAct = actionsToShow_[b] as WeaponAction; //If this weapon action can't be used, we need to reduce the current action count by 1 if (!wpAct.CanCharacterUseAction(CombatManager.globalReference.actingCharacters[0])) { b -= 1; } } //If the action isn't a weapon action, we can display it normally else { this.actionButtons[b].nameText.text = actionsToShow_[b].actionName; this.actionButtons[b].descriptionText.text = actionsToShow_[b].actionDescription; this.actionButtons[b].buttonComponent.interactable = true; } } //If there are no more actions to display, the rest of the buttons are disabled else { this.actionButtons[b].nameText.text = ""; this.actionButtons[b].descriptionText.text = ""; this.actionButtons[b].buttonComponent.interactable = false; } } }
void SelectWeapon(int selectedWeaponIndex) { for (int i = 0; i < this.weapons.Length; i++) { if (i == selectedWeaponIndex) { weapons[i].SetActive(true); this.currentWeapon = weapons[i].GetComponent <WeaponAction>(); this.currentWeapon.OnChangeAmmo.RemoveAllListeners(); this.currentWeapon.OnChangeAmmo.AddListener(this.OnWeaponReload); this.currentWeapon.OnChangeAmmo.Invoke(); aimCursor.enabled = this.currentWeapon.aimCursorSprite != null; ammoCountText.enabled = this.currentWeapon.useAmmo; ammoCountImage.enabled = this.currentWeapon.ammoCountSprite != null; aimCursor.sprite = this.currentWeapon.aimCursorSprite; ammoCountImage.sprite = this.currentWeapon.ammoCountSprite; } else { weapons[i].SetActive(false); } } }
void EmptyAllSlots() { for (int i = 0; i < CONTROLLER_INPUT_BUTTONS; i++) { WeaponAction a = GetAction((ControllerActionInput)i); a.targetAnim = null; } }
public void AddWeaponAction(WeaponAction actionWeapon) { if (actionWeapon != null) { //Debug.Log("actionWeapon action not null"); m_WeaponActionNumber++; m_WeaponActions.Add(actionWeapon); } }
protected ControllerActionManager() { for (int i = 0; i < CONTROLLER_INPUT_BUTTONS; i++) { WeaponAction a = new WeaponAction(); a.inputButton = (ControllerActionInput)i; actionSlots.Add(a); } }
public void UnbindAction(WeaponAction action, WeaponEvent pressedAction, WeaponEvent releasedAction) { switch (action) { case WeaponAction.Attack: AttackPressed -= pressedAction; AttackReleased -= releasedAction; break; case WeaponAction.Throw: ThrowPressed -= pressedAction; ThrowReleased -= releasedAction; break; } }
private void ResetActions() { currentFrame = 0; currentAction = null; foreach (AttackAction attack in attacks) { attack.CancelAction(); } foreach (ComboAction combo in combos) { combo.ResetCombo(); } }
public float WeaponCheck(float energy) { //check should look for attack input, combos, blocking //function to check for inputs, bool to track if an action is running //while an attack is playing, check for combos //needs to output energy cost //holding block should drain stamina float weaponCost = 0.0f; if (currentAction == null) { weaponCost = ActionStart(energy); } else { if (currentAction.actionType == WeaponAction.typeOfAction.Attack) { ActionUpdate(); } if (currentAction.actionType == WeaponAction.typeOfAction.Attack || currentAction.actionType == WeaponAction.typeOfAction.Combo || currentAction.actionType == WeaponAction.typeOfAction.Counter) { if (dash.DashStart(energy)) { currentAction.CancelAction(); currentAction = dash; return(dash.energyCost); } } if (currentAction.actionType == WeaponAction.typeOfAction.Block) { if (counter.CounterStart()) { currentAction.CancelAction(); currentAction = counter; return(counter.energyCost); } } if (CheckCooldown()) { ResetActions(); } } return(weaponCost); }
public void UpdateLeftActionSlot(Weapon leftWeapon) { ActionSlot LTSlot = this.GetActionSlot(ActionInputType.LT); WeaponAction lw_lt = leftWeapon.GetAction(ActionInputType.LT); LTSlot.AnimationName = lw_lt.AniName; LTSlot.Mirror = lw_lt.Mirror; LTSlot.ActionType = lw_lt.ActionType; ActionSlot LBSlot = this.GetActionSlot(ActionInputType.LB); WeaponAction lw_lb = leftWeapon.GetAction(ActionInputType.LB); LBSlot.AnimationName = lw_lb.AniName; LBSlot.Mirror = lw_lb.Mirror; LBSlot.ActionType = lw_lb.ActionType; }
public void UpdateRightActionSlot(Weapon rightWeapon) { ActionSlot RTSlot = this.GetActionSlot(ActionInputType.RT); WeaponAction rw_rt = rightWeapon.GetAction(ActionInputType.RT); RTSlot.AnimationName = rw_rt.AniName; RTSlot.Mirror = rw_rt.Mirror; RTSlot.ActionType = rw_rt.ActionType; ActionSlot RBSlot = this.GetActionSlot(ActionInputType.RB); WeaponAction rw_rb = rightWeapon.GetAction(ActionInputType.RB); RBSlot.AnimationName = rw_rb.AniName; RBSlot.Mirror = rw_rb.Mirror; RBSlot.ActionType = rw_rb.ActionType; }
// Update is called once per frame void Update() { //oldHP = p2.currHealth; if (shootScript.isAiming) { weaponScript = GameObject.FindGameObjectWithTag("Grenade").GetComponent <WeaponAction>(); } if (oldHP != p2.currHealth) { string[] temp = HPTextP2.text.Split(':'); HPTextP2.text = temp[0] + ": " + p2.currHealth + "/" + p2.maxHealth; fillAmount2 = Map(p2.currHealth, 0, p2.maxHealth, 0, 1); } HandleBar2(); }
public void MapControllerAtkActions() { WeaponList weaponList = blackboard.weaponList; switch (blackboard.currentWeapon) { case WeaponStatus.OneHanded: EmptyAllSlots(); for (int i = 0; i < weaponList.oneHandedSwordActions.Count; i++) { WeaponAction a = GetAction(weaponList.oneHandedSwordActions[i].inputButton); a.targetAnim = weaponList.oneHandedSwordActions[i].targetAnim; } break; case WeaponStatus.TwoHanded: EmptyAllSlots(); for (int i = 0; i < weaponList.twoHandedSwordActions.Count; i++) { WeaponAction a = GetAction(weaponList.twoHandedSwordActions[i].inputButton); a.targetAnim = weaponList.twoHandedSwordActions[i].targetAnim; } break; case WeaponStatus.None: EmptyAllSlots(); for (int i = 0; i < weaponList.meleeActions.Count; i++) { WeaponAction a = GetAction(weaponList.meleeActions[i].inputButton); a.targetAnim = weaponList.meleeActions[i].targetAnim; } break; default: EmptyAllSlots(); for (int i = 0; i < weaponList.meleeActions.Count; i++) { WeaponAction a = GetAction(weaponList.meleeActions[i].inputButton); a.targetAnim = weaponList.meleeActions[i].targetAnim; } break; } }
//------------------------------------------------------------------------------------------------------------------------------------------- private float ActionStart(float energyPercent) { if (dash.DashStart(energyPercent)) { currentAction = dash; return(dash.energyCost); } //check for attacks and all combos that start with that attack foreach (AttackAction attack in attacks) { if (attack.EnergyComapre(energyPercent)) { if (attack.AttackStart()) { //attack action is active currentAction = attack; currentFrame = 0; foreach (ComboAction combo in combos) { if (combo.ContinueCombo(attack.buttonName, currentFrame)) { print("Combo Started"); } } return(attack.energyCost); } } } //check for block if (block.BlockCheck(energyPercent)) { currentAction = block; return(block.energyCost); } return(0.0f); }
private void ActionUpdate() { foreach (AttackAction attack in attacks) { if (attack.AttackCheck()) { foreach (ComboAction combo in combos) { if (combo.ComboEnabled()) { combo.ContinueCombo(attack.buttonName, currentFrame); if (combo.CheckComboComplete()) { currentAction.CancelAction(); currentAction = combo; } } } } } }
// Update is called once per frame void Update() { //oldHP = p1.currHealth; if (shootScript.isAiming) { weaponScript = GameObject.FindGameObjectWithTag("Grenade").GetComponent <WeaponAction>(); } //if(oldHP != p1.currHealth) { string[] temp = HPTextP1.text.Split(':'); //HPTextP1.text = temp[0] + ": " + p1.currHealth + "/" + p1.maxHealth; //fillAmount = Map(p1.currHealth, 0, p1.maxHealth, 0, 1); } // if(p1.currHealth == 0) { FindObjectOfType <AudioManager>().Play("Noooo"); } HandleBar(); }
public WeaponAction ComputeWeaponAction(List <SpaceObject> targets, Weapon weapon) { if (targets == null || targets.Count == 0) { return(null); } WeaponAction actionWeapon = new WeaponAction(weapon); foreach (SpaceObject currentTarget in targets) { float currentScore = weapon.ComputeScore(currentTarget); if (currentScore > actionWeapon.m_Score) { SpaceObject newTarget = currentTarget; actionWeapon.m_Target = newTarget; actionWeapon.m_Score = currentScore; //Debug.Log("current target = " + newTarget.gameObject.name + " / current score = " + currentScore); } } return(actionWeapon); }
private void Start() { weapon = gameObject.GetComponentInParent <WeaponAction>(); }
protected override void OnUpdate() { for (int i = 0; i < data.Length; i++) { WeaponComponent weaponComponent = data.weaponComponent[i]; WeaponState weaponState = data.weaponState[i]; WeaponAction weaponAction = data.weaponAction[i]; Entity entity = data.entities[i]; LineRenderer lineRenderer = weaponComponent.lineRenderer; Transform weaponTransform = weaponComponent.lineRenderer.transform; lineRenderer.SetPosition(0, weaponTransform.position); weaponState.reloadTimer = math.max(0, weaponState.reloadTimer - Time.deltaTime); weaponState.fireTimer = math.max(0, weaponState.fireTimer - Time.deltaTime); weaponState.effectTimer = math.max(0, weaponState.effectTimer - Time.deltaTime); if (lineRenderer.enabled && weaponState.effectTimer == 0) { lineRenderer.enabled = false; } if (weaponState.reloading && weaponState.reloadTimer == 0) { weaponState.magazine = weaponComponent.magazinSize; weaponState.reloading = false; } if (weaponAction.reload && weaponState.magazine < weaponComponent.magazinSize && !weaponState.reloading) { weaponState.reloadTimer = weaponComponent.reloadTime; weaponState.reloading = true; } if (weaponAction.fire && weaponState.magazine > 0 && weaponState.fireTimer == 0 && !weaponState.reloading) { lineRenderer.enabled = true; weaponState.fireTimer = weaponComponent.fireRate; weaponState.magazine--; if (Physics.SphereCast(weaponAction.shootOrigin, 0.5f, weaponAction.shootDir, out RaycastHit hit, weaponComponent.range)) { lineRenderer.SetPosition(1, hit.point); PostUpdateCommands.CreateEntity(); GameObjectEntity hittenGameObjectEntity = hit.collider.GetComponent <GameObjectEntity>(); if (hittenGameObjectEntity) { PostUpdateCommands.AddComponent(new DamageInfo { source = entity, receiver = hittenGameObjectEntity.Entity, damage = weaponComponent.damage }); } } else { lineRenderer.SetPosition(1, weaponTransform.position + weaponTransform.forward * weaponComponent.range); } } data.weaponState[i] = weaponState; }
public void Shoot() { WeaponAction.Shoot(); }
public void RemoveWeaponAction(WeaponAction weaponAction) { WeaponActions.Remove(weaponAction); }
public void QueueWeaponAction(WeaponAction weaponAction) { WeaponActions.Add(weaponAction); }
void Update() { // checks which players turn it is if (GameManager.instance.p1Turn) { playerScript = GameObject.Find("Player1").GetComponent <Player1> (); } else if (GameManager.instance.p2Turn) { playerScript2 = GameObject.Find("Player2").GetComponent <Player2> (); } // adds a click listener for each weapon weaponButton.onClick.AddListener(delegate { ChooseWeapon(weaponButton); }); weaponButton2.onClick.AddListener(delegate { ChooseWeapon(weaponButton2); }); //weaponButton3.onClick.AddListener (delegate{ChooseWeapon(weaponButton3);}); //weaponButton4.onClick.AddListener (delegate{ChooseWeapon(weaponButton4);}); // For Final Presentation // This restricts the players touches to only spawn and throw the grenade to the top half // of the users screen, so it will persist on any device if (Input.mousePosition.y > Screen.height / 2) { if (Input.GetMouseButtonDown(0) && !isAiming && !isThrown) { if (objectCount == 1) { Destroy(previousWeapon); objectCount = 0; } if (!isThrown) { Spawn(); objectCount++; } } else if (Input.GetMouseButtonDown(0) && isAiming) { launch(); } } // if the player is aiming then allow the player to rotate the grenade around them if (isAiming) { weaponScript = GameObject.FindGameObjectWithTag(currentWeapon.tag).GetComponent <WeaponAction>(); move = 0; move = CrossPlatformInputManager.GetAxis("Horizontal"); if (GameManager.instance.p1Turn) { if (playerScript.isFacingLeft && move > 0 && !weaponScript.maxRight) { previousWeapon.transform.RotateAround(playerTrans.position, Vector3.forward, -rotateSpeed * Time.deltaTime); } else if (playerScript.isFacingLeft && move < 0 && !weaponScript.maxLeft) { previousWeapon.transform.RotateAround(playerTrans.position, Vector3.forward, rotateSpeed * Time.deltaTime); } else if (!playerScript.isFacingLeft && move > 0 && !weaponScript.maxRight) { previousWeapon.transform.RotateAround(playerTrans.position, Vector3.forward, -rotateSpeed * Time.deltaTime); } else if (!playerScript.isFacingLeft && move < 0 && !weaponScript.maxLeft) { previousWeapon.transform.RotateAround(playerTrans.position, Vector3.forward, rotateSpeed * Time.deltaTime); } } else if (GameManager.instance.p2Turn) { if (playerScript2.isFacingLeft && move > 0 && !weaponScript.maxRight) { previousWeapon.transform.RotateAround(playerTrans2.position, Vector3.forward, -rotateSpeed * Time.deltaTime); } else if (playerScript2.isFacingLeft && move < 0 && !weaponScript.maxLeft) { previousWeapon.transform.RotateAround(playerTrans2.position, Vector3.forward, rotateSpeed * Time.deltaTime); } else if (!playerScript2.isFacingLeft && move > 0 && !weaponScript.maxRight) { previousWeapon.transform.RotateAround(playerTrans2.position, Vector3.forward, -rotateSpeed * Time.deltaTime); } else if (!playerScript2.isFacingLeft && move < 0 && !weaponScript.maxLeft) { previousWeapon.transform.RotateAround(playerTrans2.position, Vector3.forward, rotateSpeed * Time.deltaTime); } } } }