void Start() { controller = GetComponent <CharacterController>(); actions = GetComponent <PlayerActionController>(); currentMoveMode = MoveMode.normal; currentJumpMode = JumpMode.grounded; }
public override void Init() { movementController = GetComponent <PlayerMovementController>(); actionController = GetComponent <PlayerActionController>(); rotationController = GetComponent <PlayerRotationController>(); animationController = GetComponent <PlayerAnimationController>(); inventoryController = GetComponent <PlayerInventoryController>(); weaponController = GetComponent <PlayerWeaponController>(); healthController = GetComponent <HealthController>(); reloadController = GetComponent <PlayerReloadController>(); interactionController = GetComponent <InteractionSearcherController>(); executionController = GetComponent <PlayerExecutionController>(); limbsController = GetComponentInChildren <LimbsController>(); hitboxController = GetComponentInChildren <HitboxController>(); abilityController = GetComponent <AbilityController>(); tickPlayer.value = true; movementController.Init(); actionController.Init(); rotationController.Init(); animationController.Init(); weaponController.Init(); inventoryController.Init(); healthController.Init(); reloadController.Init(); interactionController.Init(); executionController.Init(); limbsController.Init(); hitboxController.Init(); abilityController.Init(); }
// Use this for initialization private void Start() { LevelController = new LevelController(FindObjectOfType <SceneLoader>()); GC = FindObjectOfType <GameController>(); ActionController = GetComponent <PlayerActionController>(); ToolController = GetComponent <ToolController>(); }
// Use this for initialization void Awake() { ps = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerScript>(); pac = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerActionController>(); //AUI = GameObject.FindGameObjectWithTag("ActionUI"); AUI = GameObject.Find("Canvas").transform.FindChild("Joystick_Action").transform.FindChild("ActionUI").gameObject; AUI.SetActive(true); }
protected override void Start() { base.Start(); ActionController = new PlayerActionController(this); _playerWidnow.InitComponents(); PlayerInventoryController = new PlayerInventoryController(this); PlayerEquipmentController = new PlayerEquipmentController(this); }
override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { controller = animator.GetComponentInParent <PlayerActionController>(); controller.m_rigidbody.velocity = Vector2.zero; controller.m_rigidbody.AddForce(Vector2.up * controller.Info.JumpPower, ForceMode2D.Impulse); AudioSourceManager.Instance.PlayOneShot(controller.Info.JumpClip); controller.MoveAction(); }
//Tower Placement Player Action. //These 2 methods handle assignments to the placement_in_progress flag as well as sending the PlayerActionController transmissions private void StartTowerPlacement(object caller, TowerPlacementEventArgs args) { PlayerActionController.StartPlayerAction(); flag_placement_in_progress = true; //Find a tower with the name matching our argument tower_to_place = Tower_Manager_V2.GetTowerPrefabList().Find(x => x.tower_name == args.tower_name); //fancy predicate using Linq! //Debug.Log("Tower to place is ID of: " + tower_to_place.gameObject.ToString()); }
public static void HandleDodgeEvent(InputData iData) { if (playerList.ContainsKey(iData.PlayerNum)) { PlayerActionController p = playerList[iData.PlayerNum].GetComponent <PlayerActionController>(); p.TriggerDodge(); } return; }
private void EndTowerPlacement() { if (flag_placement_in_progress) { //Debug.Log("placement event canceled"); PlayerActionController.EndPlayerAction(); RemoveGhost(); flag_placement_in_progress = false; } }
// Use this for initialization void Start() { // Initialize references playerRigidbody = GetComponent <Rigidbody2D>(); playerActionController = GetComponent <PlayerActionController>(); playerInfo = GetComponent <PlayerInfo>(); // Initialize variables movSpeed = 4f; rotSpeed = 10f; }
// Unity Events: protected override void Awake() { // Anything needed to be passed into the States need to be done BEFORE base.Awake() actionController = GetComponent <PlayerActionController>(); playerInputData = GetComponent <PlayerInputData>(); weapons = GetComponent <PlayerWeapons>(); base.Awake(); // Anything that is NOT used by States can be done after }
public PlayerMediumActionState(PlayerStateController playerController, StateMachine stateMachine) { this.playerController = playerController; this.stateMachine = stateMachine; movementController = playerController.movementController; actionController = playerController.actionController; animationController = playerController.animationController; animations = (PlayerAnimations)animationController.animationsList; animate = animationController.animate; }
private void TryDisplayOptions(object sender, TowerV2RefEventArgs args) { if (PlayerActionController.PlayerActionAvailable()) { StopDisplayingOptions(); Debug.Log("Displaying Options"); UpdateOptionsList(args.tower.selection_options_list); UpdateSelectedMonobehavior(args.tower); StartDisplayingOptions(); } }
private void StartDisplayingOptions() { if (PlayerActionController.PlayerActionAvailable()) //possibly redundant but good for protection { //Changed this feature to just autocancel if another starts //PlayerActionController.StartPlayerAction(); //it is CRITICAL this comes before flag setting cur_selection_indicator = Instantiate(selection_indicator_model, cur_selected_monobehavior.transform.position + new Vector3(0, 7), Quaternion.identity); //TODO: remove magic vector OnStartSelectEvent?.Invoke(this, new MonobehaviourEventArgs(cur_selected_monobehavior)); flag_options_display_in_progress = true; } }
void OnTriggerEnter(Collider other) { if (other.name == otherPlayer.name) { PlayerActionController otherPlayerActionController = other.GetComponent <PlayerActionController>(); MoveScriptCharacterController otherPlayerMoveScript = other.GetComponent <MoveScriptCharacterController>(); float multiplier = playerAction.TimeSinceHoldStart > 0 ? playerAction.TimeSinceHoldStart : 1; int damage = (int)(playerActionController.CurrentAttackDamage * multiplier); otherPlayerMoveScript.Stagger(Mathf.Sqrt(damage) * 0.0056f, Mathf.Sqrt(damage) * 2, this.transform.position); if (playerActionController.ActionInProgress && !otherPlayerActionController.blocking) { otherPlayer.GetComponent <PlayerHealth>().TakeDamage(damage); } } //NOT IMPLEMENTED }
private void Awake() { if (Application.isEditor) { PlayerPrefs.SetInt("Attack", 1); PlayerPrefs.SetInt("Taunt", 1); PlayerPrefs.SetInt("Overreact", 1); } player = GameObject.FindGameObjectWithTag("Player").gameObject; //playerScript = player.GetComponent<Player>(); playerScript = player.GetComponent <PlayerScript>(); moving = false; SX = 0; SY = 0; _stickTransform = Stick.GetComponent <RectTransform>(); _baseTransform = ActionUI.GetComponent <RectTransform>(); //_baseTransformTop = ActionTop.GetComponent<RectTransform>(); //_baseTransformBottom = ActionBottom.GetComponent<RectTransform>(); _initialStickPosition = _stickTransform.anchoredPosition; _intermediateStickPosition = _initialStickPosition; //_initialBasePositionTop = _baseTransform.anchoredPosition; _stickTransform.anchoredPosition = _initialStickPosition; _baseTransform.anchoredPosition = _initialBasePosition; xClamp = GetComponent <RectTransform>().rect.width + (transform.parent.GetComponent <RectTransform>().rect.width / 2) - ((_baseTransform.rect.width / 2) + (_stickTransform.rect.width / 2)) - 120; //xClamp = GetComponent<RectTransform>().rect.width + (transform.parent.GetComponent<RectTransform>().rect.width / 2) - xClamp; yBotClamp = (_baseTransform.rect.height / 2) + (_stickTransform.rect.height / 2) + 120; yTopClamp = GetComponent <RectTransform>().rect.height - yBotClamp; _oneOverMovementRange = 1f / MovementRange; if (HideOnRelease) { Hide(true); } playerActionController = player.GetComponent <PlayerActionController>(); }
public void TauntCooldown() { PlayerActionController pAction = GameObject.Find("Player").GetComponent <PlayerActionController>(); if (!tauntCD) { tauntCD = true; pAction.SetTauntCooldown(5f); // pAction.taun Debug.Log(" TRUE"); } else { tauntCD = false; pAction.SetTauntCooldown(0f); // pAction.TauntCooldown = 0f; Debug.Log(" FALSe"); } }
void Awake() { OxygenBar = OxygenBarObject.GetComponent <Slider>(); OxygenBarText = OxygenBarObject.GetComponentInChildren(typeof(Text), true) as Text; HealthBar = HealthBarObject.GetComponent <Slider>(); HealthBarText = HealthBarObject.GetComponentInChildren(typeof(Text), true) as Text; StaminaBar = StaminaBarObject.GetComponent <Slider>(); PlayerController = GetComponent <RigidbodyFirstPersonController>(); PlayerActionController = GetComponent <PlayerActionController>(); PointsText = PointsTextObject.GetComponent <Text>(); BeaconController = GetComponent <BeaconLocationController>(); AmmoText = AmmoTextObject.GetComponent <Text>(); Notifications = NotificationObject.GetComponent <NotificationController>(); SoundEffect = GetComponent <AudioSource>(); // Set Oxygen to Max Oxygen = MaxOxygen; // Set Oxygen Slider Max Value OxygenBar.maxValue = MaxOxygen; // Set Health Slider Max Value HealthBar.maxValue = startingHealth; // Set Stamina Slider Max Value StaminaBar.maxValue = MaxStamina; // Set Points Text SetPointsText(Points); // Start OxygenTick Invoke("OxygenTick", 1f); // Initialize Player Health currentHealth = startingHealth; // Initialize Stamina PlayerStamina = MaxStamina; }
public static bool DoAOEAttack(Vector3 pos, float radius, float force, float playerForce, MonsterAI Monster) { Collider[] Colliders = new Collider[0]; Colliders = Physics.OverlapSphere(pos, radius); for (int i = 0; i < Colliders.Length; i++) { MonsterAI m = Colliders[i].GetComponent <MonsterAI>(); if (m != null) { //Hit a sheep if (m.GetType().Equals(typeof(SheepAI))) { Monster.HitSheep(m.GetComponent <QuestObject>(), m, m.gameObject, force, false, Monster); } else { //Debug.Log("WTF ATTACKED PLAYER??" + m.name); //hit monster //Monster.playerAction.MonsterAttackedMonster(Monster); } } //Debug.Log("One in range"); if (Colliders[i].tag == "Player") { //Debug.Log("This on is a player"); Rigidbody body = Colliders[i].transform.GetComponent <Rigidbody>(); if (body) { //Debug.Log(playerForce); body.AddExplosionForce(playerForce, pos, radius); } PlayerActionController PAC = Colliders[i].gameObject.GetComponent <PlayerActionController>(); PAC.PlayerAttacked(Monster); return(true); } } return(false); }
protected override void Update() { base.Update(); if (LocalPlayer != null && _itemImage != null) { UpdateHeldItem(); } PlayerActionController controller = PlayerActionController.Current; if (controller != null) { if (controller.ActiveHand == _slotEnum) { _renderer.sprite = _activeSprite; } else { _renderer.sprite = _inactiveSprite; } } }
public void ApplyItemClient(Item.Item item) { //Debug.Log("Table was clicked!"); PlayerActionController controller = PlayerActionController.Current; Humanoid localPlayer = controller.LocalPlayerMob as Humanoid; if (localPlayer == null) { return; } Item.Item heldItem = localPlayer.GetItemBySlot(controller.ActiveHand); if (heldItem == item) { // Calculating item offset Vector2 mousePosition = controller.MouseWorldPosition; Vector2 tablePosition = transform.position; Vector2 offset = mousePosition - tablePosition; localPlayer.DropItem(controller.ActiveHand, Cell, offset); } }
void Awake() { instance = this; }
/// <summary> /// The player throws (Action1) the picked up object /// </summary> /// <returns>Returns true if it was thrown</returns> public bool ActionThrow(PlayerActionController ac, float throwStrength, Vector3 direction) { if (canBeThrown) Throw(ac, throwStrength, direction); return canBeThrown; }
/// <summary> /// The target object is dragged around. /// </summary> /// <param name="ac">The player's action controller</param> void Drag(PlayerActionController ac) { ac.SetHeldObject(this, this.heldHandType); this.physicsCollider.gameObject.layer = LayerMask.NameToLayer("PickedupObject"); // Follow the position var posAttractor = GetComponent<PositionAttractor>(); posAttractor.heightIsNotAffected = true; posAttractor.targetTr = ac.pickingUpPivotTr; posAttractor.enabled = true; // Follow the rotation var rotAttractor = GetComponent<OrientationAttractor>(); rotAttractor.targetTr = ac.pickingUpPivotTr; rotAttractor.enabled = true; // Slow down player Statics.instance.playerMovementController.SetSpeedModifier(0.5f); Statics.instance.playerMovementController.DisableJump(); // No gravity this.rigidbody.useGravity = true; }
// Use this for initialization void Start() { rootObject = gameObject.transform.root.gameObject; playerAction = rootObject.GetComponent <PlayerAction>(); playerActionController = rootObject.GetComponent <PlayerActionController>(); }
/// <summary> /// The current held object is dropped. /// </summary> /// <param name="ac">The player's action controller</param> void Drop(PlayerActionController ac) { // If it was held in hand if (canBeHeld) { this.gameObject.SetActive(true); float dropBackOffset = 1f; this.transform.position = ac.transform.position + ac.transform.forward * (-dropBackOffset); float castDistance = 1f; // AC pos //Debug.Log("Check dropping: AC position " + ac.transform.position); //Debug.DrawRay(ac.transform.position, Vector3.up, Color.red, 2.0f); // FROM pos //Debug.Log("Check dropping: FROM position " + this.transform.position); //Debug.DrawRay(this.transform.position, Vector3.up, Color.blue, 2.0f); // RAYCAST //Debug.Log("Check dropping: FROM position " + this.transform.position); //Debug.DrawRay(this.transform.position, ac.transform.forward * castDistance, Color.magenta, 2.0f); // Check if we can drop it here RaycastHit hitInfo; LayerMask mask = 1 << LayerMask.NameToLayer("PlayerTrigger"); mask = ~mask; if (!Physics.Raycast(this.transform.position, ac.transform.forward, out hitInfo, castDistance, mask)) { //Debug.Log("We can drop it!"); // Can drop it here, drop it with a velocity impulse this.transform.position += ac.transform.forward * dropBackOffset / 2; // We move it a bit farther this.rigidbody.AddForce(ac.transform.forward * DROP_IMPULSE, ForceMode.VelocityChange); } else { //Debug.Log("We cannot drop it! Leave it just in front of us! We hit a " + hitInfo.collider.gameObject.name); // Cannot drop it here, just drop it without an impulse float feetDistance = 0.5f; float forwardOffset = 0.45f; this.transform.position = Statics.instance.playerMovementController.transform.position; this.transform.position += Vector3.down * feetDistance; // A bit downfloat forwardOffset = 0.1f; this.transform.position += Statics.instance.playerMovementController.transform.forward * forwardOffset; // A bit forward //Debug.DrawRay(this.transform.position, Vector3.up, Color.black, 2.0f); } } // If it was dragged or picked up else if (canBeDragged || canBePickedUp) { this.physicsCollider.gameObject.layer = LayerMask.NameToLayer("Default"); // Just drop it var posAttractor = GetComponent<PositionAttractor>(); posAttractor.enabled = false; var rotAttractor = GetComponent<OrientationAttractor>(); rotAttractor.enabled = false; } // Reset player movement modifier settings Statics.instance.playerMovementController.ResetSpeedModifier(); Statics.instance.playerMovementController.ResetDisableJump(); this.transform.parent = null; this.rigidbody.useGravity = true; ac.ClearHeldObject(); }
/// <summary> /// The target object is held in hand. /// </summary> /// <param name="ac">The player's action controller</param> void HoldInHand(PlayerActionController ac) { ac.SetHeldObject(this, this.heldHandType, inHand:true); // This object disappears, as it will appear in hand this.gameObject.SetActive(false); }
/// <summary> /// The target object is picked up. /// </summary> /// <param name="ac">The player's action controller</param> void PickUp(PlayerActionController ac) { ac.SetHeldObject(this, this.heldHandType); // Parenting: uncomment this to achieve non-physical motion //this.transform.parent = ac.pickingUpPivotTr; this.physicsCollider.gameObject.layer = LayerMask.NameToLayer("PickedupObject"); // Follow the position var posAttractor = GetComponent<PositionAttractor>(); posAttractor.heightIsNotAffected = false; posAttractor.targetTr = ac.pickingUpPivotTr; posAttractor.enabled = true; // Follow the rotation var rotAttractor = GetComponent<OrientationAttractor>(); rotAttractor.targetTr = ac.pickingUpPivotTr; rotAttractor.enabled = true; // No gravity this.rigidbody.useGravity = false; }
/// <summary> /// The current held object is thrown. /// </summary> /// <param name="ac">The player's action controller</param> /// <param name="throwStrength">Strength with which to throw the action</param> /// <param name="direction">Direction of the throw</param> void Throw(PlayerActionController ac, float throwStrength, Vector3 direction) { Drop(ac); this.rigidbody.AddForce(direction*throwStrength,ForceMode.Impulse); }
// OnStateEnter is called when a transition starts and the state machine starts to evaluate this state override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { controller = animator.GetComponentInParent <PlayerActionController>(); Update(); }
/// <summary> /// The player drops (Action1) the picked up object /// </summary> /// <returns>Returns true if it was dropped</returns> public bool ActionDrop(PlayerActionController ac) { if (canBePickedUp || canBeHeld || canBeDragged) Drop(ac); return canBePickedUp || canBeHeld || canBeDragged; }
/// <summary> /// The player picks up (Action1) the pointed object /// </summary> /// <returns>Returns true if it was picked up</returns> public bool ActionPickUp(PlayerActionController ac) { if (canBePickedUp) PickUp(ac); else if (canBeDragged) Drag(ac); else if (canBeHeld) HoldInHand(ac); bool ok = canBePickedUp || canBeDragged || canBeHeld; if (activationMethod == ActivationMethod.PICK_UP && ok) Activate(); return ok; }
protected override void Start() { base.Start(); ActionController = new PlayerActionController(this); }
void Initialise() { playerMovementController = GameObject.FindObjectOfType<RigidbodyFirstPersonController>(); playerActionController = GameObject.FindObjectOfType<PlayerActionController>(); }