public void PushStart(CharacterBehaviour handler) { master = handler; master.onPush = true; initDist = Mathf.Min(Mathf.Abs(master.transform.position.x - transform.position.x), (transform.localScale.x * col.size.x / 2 + master.col.size.x)); transform.position = new Vector3(master.transform.position.x + (master.transform.position.x - transform.position.x < 0f ? 1f : -1f) * initDist, transform.position.y); }
public void InteractPress(CharacterBehaviour character) { if (character == PlayerController.Instance && Interactable) { ArenaManager.ArenaManagerInstance.StartRound(); } }
void FindVisibleTargets(float viewRadius) { Vector3 bottom = new Vector3(transform.position.x, transform.position.y - _viewHeight, transform.position.z); Vector3 top = new Vector3(transform.position.x, transform.position.y + _viewHeight, transform.position.z); Collider[] targetsInViewRadius = Physics.OverlapCapsule(bottom, top, viewRadius, _targetMask); // find each target that falls withing the angle range for (int i = 0; i < targetsInViewRadius.Length; i++) { Transform targetTransform = targetsInViewRadius[i].transform; if (!targetTransform.GetComponent <CapsuleCollider>()) { continue; } CapsuleCollider targetCollider = targetTransform.GetComponent <CapsuleCollider>(); Vector3 target = targetTransform.GetComponent <CapsuleCollider>().bounds.center; target.y += targetCollider.height / 2.0f; Vector3 dirToTarget = (target - transform.position).normalized; CharacterBehaviour player = targetTransform.GetComponent <CharacterBehaviour>(); float distToTarget = Vector3.Distance(transform.position, target); if (Vector3.Angle(transform.forward, dirToTarget) < _viewAngle / 2) { float dstToTarget = Vector3.Distance(transform.position, target); Vector3 targetFlatPos = new Vector3(target.x, transform.position.y, target.z); float horizontalDstToTarget = Vector3.Distance(transform.position, targetFlatPos); float checkHeight = ((horizontalDstToTarget / viewRadius) * _viewHeight) + 1.0f; float heightDif = transform.position.y - target.y; if (!Physics.Raycast(transform.position, dirToTarget, dstToTarget, _obstacleMask) && !_visibleTargets.Contains(_enemy.target) && (heightDif <= checkHeight || heightDif >= -checkHeight)) { FoundPlayer(targetTransform); } else if (_visibleTargets.Contains(_enemy.target) && Physics.Raycast(transform.position, dirToTarget, dstToTarget, _obstacleMask) || (heightDif > checkHeight || heightDif < -checkHeight)) { LostPlayer(); } } else if (player && distToTarget <= _runningNearDetection) { bool playerCrouching = player.IsCrouching; bool playerMoving = player.IsMoving; bool playerAlreadySeen = _visibleTargets.Contains(_enemy.target); if (!playerCrouching && playerMoving && !playerAlreadySeen) { FoundPlayer(targetTransform); } } else if (_visibleTargets.Contains(_enemy.target)) { LostPlayer(); } } }
protected override void ExecuteAction(CharacterBehaviour character) { if (!_canMove) { _canMove = true; } }
// disables or enables the player based on entered bool void DisablePlayer(bool pSetDisable) { /** Tell teleport script you are in a keypad before the script is called to be disabled */ if (!_teleportScript) { _teleportScript = _player.GetComponent <TeleportScript>(); } _teleportScript.isInKeypad = pSetDisable; foreach (MonoBehaviour script in _player.GetComponents <MonoBehaviour>()) { script.enabled = !pSetDisable; } _characterBehaviour = _player.GetComponent <CharacterBehaviour>(); _characterControllerScheme = _player.GetComponent <CharacterControllerScheme>(); if (pSetDisable) { _characterBehaviour.SetPhysicsColider(false); _characterControllerScheme.StopMovement(); } if (!pSetDisable) { _characterBehaviour.SetPhysicsColider(true); } }
private void Start() { m_character = GetComponent <CharacterBehaviour>(); m_combatState = CombatState.WAITING; m_path = new NavMeshPath(); NavMesh.CalculatePath(transform.position, m_targetCharacter.transform.position, NavMesh.AllAreas, m_path); }
void Start() { _shouldSpeak = true; _projSpawned = false; _CB = GetComponent <CharacterBehaviour>(); _animator = GetComponent <Animator>(); _charging = false; if (!_camController) { // Debug.LogWarning("No CameraController reference in inspector. Looking up object."); _camController = Camera.main.GetComponent <CameraController>(); } if (!_projectilePrefab) { Debug.LogError("No prefab for projectile"); } if (!_projectileSpawn) { Debug.LogError("No spawnpoint for projectile"); } // if (!_coolDown) // { // // Debug.LogWarning("No CoolDown reference in inspector. Looking up object."); // _coolDown = GameObject.Find("CoolDownProj").GetComponent<CoolDown>(); // } /** Check to see if there is an OnPlayerHUD */ if (!_onPlayerHUD) { _onPlayerHUD = GetComponent <OnPlayerHUD>(); } }
private void Start() { if (parentCharacter == null) { parentCharacter = GetComponentInParent <CharacterBehaviour>(); } }
public void SaveCharacter(GameObject character) { CharacterData saveData = new CharacterData(); CharacterBehaviour behaviour = character.GetComponent <CharacterBehaviour>(); CharacterLoadout loadout = character.GetComponent <CharacterLoadout>(); // Save Character saveData.CharacterName = behaviour.Name; saveData.CharacterId = behaviour.Id; saveData.CharacterLevel = behaviour.Level; saveData.CharacterExp = behaviour.Experience; saveData.AvailablePoints = loadout.AvailablePoints; // Save common stats saveData.MoveSpeedStat = loadout.moveSpeedStat.ToSerializeable(); // To eventually support multiple ability selections be character saveData.Abilities = new Ability.SerializableAbility[] { loadout.Ability1.ToSerializeable(), loadout.Ability2.ToSerializeable() }; saveData.Ability1Index = 0; saveData.Ability2Index = 1; string jsonCharacterBlob = JsonUtility.ToJson(saveData); string characterFilePath = CharacterSaveLocation + saveData.CharacterId + fileExtension; File.WriteAllText(characterFilePath, jsonCharacterBlob); }
public virtual void CheckVision() { // TODO: IMPLEMENT THIS FUNCTION if (CurrentTarget != null) { if (CanSeeTarget(CurrentTarget.BodyTransform)) { ReactToCharacter(CurrentTarget); } else { currentTarget = null; } return; } foreach (CharacterBehaviour character in knownCharacters) { if (CanSeeTarget(character.BodyTransform)) { ReactToCharacter(character); } } }
void OnLoadOperationComplete(AsyncOperation ao) { if (_loadOperations.Contains(ao)) { _loadOperations.Remove(ao); if (_loadOperations.Count == 0) { UpdateState(GameState.RUNNING); //THIS IS TEMPORARY TO SEE IF IT REALLY WAITF FOR LOAD TO FINISH characterBehaviour = player.GetComponent <CharacterBehaviour>(); //FIND THE LEVEL MANAGER FROM EACH SCENE WHEN IT HAS FINISHED LOADING if (CharacterInstructions.Instance != null) { CharacterInstructions.Instance.GetLevelManager(); } else { return; } characterBehaviour.GetActionsManager(); } } //WAS ORIGINALLY HERE }
// Use this for initialization void Start() { playerManager = GetComponent <PlayerManager>(); playerAnimation = GetComponent <PlayerAnimation>(); playerController = GetComponent <PlayerController>(); characterBehaviour = GetComponent <CharacterBehaviour>(); }
// For deciding the winning and losing roundss public void GiveRound(CharacterBehaviour CharacterA, CharacterBehaviour CharacterB, List <Round> RoundList, int listSize) { if (RoundList.Count != listSize) { Round tempRound = ScriptableObject.CreateInstance <Round>(); // The temp round to be added to the round list tempRound.name = "Round " + (RoundList.Count + 1).ToString(); // Naming the round if (CharacterA.character.Health > CharacterB.character.Health) { tempRound.Result = Round.RoundResult.CHARACTERAWIN; // The 1st character Set as winner of round RoundList.Add(tempRound); } else if (CharacterA.character.Health < CharacterB.character.Health) { tempRound.Result = Round.RoundResult.CHARACTERBWIN; // The 2nd character set as winner of round RoundList.Add(tempRound); } return; } else if (RoundList.Count >= listSize) // In case the list is full and the function is still called { Debug.Log("RoundList is full: " + RoundList.ToString()); return; } }
public virtual void DeregisterFromKnownCharacters(CharacterBehaviour characterBehaviour) { if (knownCharacters.Contains(characterBehaviour)) { knownCharacters.Remove(characterBehaviour); } }
public virtual void RegisterToKnownCharacters(CharacterBehaviour characterBehaviour) { if (!knownCharacters.Contains(characterBehaviour)) { knownCharacters.Add(characterBehaviour); } }
public void PushEnd() { master.onPush = false; master = null; initDist = 0f; GetComponent <MovableBehaviour>().hspeed = 0f; }
void Start() { enemyType = GetComponent <EnemyStats>().GetEnemyType(); enemyAgent = GetComponent <NavMeshAgent>(); targetTransform = GameObject.FindWithTag("Player").GetComponent <Transform>(); targetBehaviour = targetTransform.gameObject.GetComponent <CharacterBehaviour>(); basicAttackTrigger = GetComponentInChildren <AttackTrigger>(); enemyAnimator = GetComponentInChildren <Animator>(); particleInstancer = GameObject.FindWithTag("ParticleInstancer").GetComponent <ParticleInstancer>(); enemyAudioPlayer = GetComponent <AudioPlayer>(); foreach (AnimationClip clip in enemyAnimator.runtimeAnimatorController.animationClips) { switch (enemyType) { case EnemyStats.EnemyType.Skull: if (clip.name == "hit") { basicAttackDuration = clip.length; } if (clip.name == "appear") { appearDelayTime = clip.length / 1.7f; } break; case EnemyStats.EnemyType.Fenrir: if (clip.name == "jumpIn") { jumpInitDelayTime = clip.length; } if (clip.name == "jumpAttack") { jumpAttackInitTime = clip.length; } break; default: break; } } enemyAgent.SetDestination(transform.position); enemySpeed = enemyAgent.speed; enemyAngularSpeed = enemyAgent.angularSpeed; enemyAcceleration = enemyAgent.acceleration; if (enemyType == EnemyStats.EnemyType.Fenrir) { baAnimationLength = 5; } enemyHealthBar = GameObject.Find("GameplayUI").GetComponent <EnemyHealthBar>(); endingPlayer = enemyHealthBar.gameObject.GetComponent <PlayEnding>(); }
public PatrolState(CharacterBehaviour newCharacterBehaviour, Waypoint newWaypoint, NavMeshAgent newNavMeshAgent) { // set properties characterBehaviour = newCharacterBehaviour; waypoint = newWaypoint; navMeshAgent = newNavMeshAgent; }
public void NextTurn(int player) { _turn++; StopAllCoroutines(); UIManager.Instance.DisableTimer(); CharacterBehaviour characterBehaviour = selectedUnit.GetComponent <CharacterBehaviour>(); if (characterBehaviour.IsOutside()) { characterBehaviour.Die(); } characterBehaviour.ThirdCamera.SetActive(false); characterBehaviour.DisableControls(); canSelectUnit = true; topDownCamera.enabled = true; topDownCamera.GetComponent <CameraController>().enabled = true; if (player == 1) { _whichPlayer = 2; } else if (player == 2) { _whichPlayer = 1; } UIManager.Instance.ClickOnUnitActive(_whichPlayer); }
private void Start() { healthBar = GameObject.Find("HealthBar").GetComponent <Image>(); passiveIcon = GameObject.Find("passiveGreyUIicon").GetComponent <Image>(); qIcon = GameObject.Find("qGreyUIicon").GetComponent <Image>(); wIcon = GameObject.Find("wGreyUIicon").GetComponent <Image>(); eIcon = GameObject.Find("eGreyUIicon").GetComponent <Image>(); rIcon = GameObject.Find("rGreyUIicon").GetComponent <Image>(); enableDisablePopUpsAnimator = GameObject.Find("enableDisablePopUps").GetComponent <Animator>(); enableDisablePopUpsAnimator.SetBool("popUpsEnabled", eventSystemEnabled); indicatorTransform = GameObject.FindWithTag("AOEIndicator").transform; indicatorProjector = indicatorTransform.gameObject.GetComponent <Projector>(); indicatorMaterial = indicatorProjector.material; AOEInidicator("none"); playerBehaviour = GameObject.FindWithTag("Player").GetComponent <CharacterBehaviour>(); playerBehaviour.GetAbilityCooldowns(out passiveCd, out qCd, out wCd, out eCd, out rCd); playerBehaviour.GetAbilityRanges(out qRange, out wRange, out eRange, out rRange); SetIconsInitFillAmount(); }
protected override void ExecuteAction(CharacterBehaviour character) { // trigger event SetActive(false); GameEvents.FSMEvents.StartInteraction.SafeInvoke(GameEnums.FSMInteractionEnum.ActivateItem); StartCoroutine(WaitToOpenDoor(0.2f)); }
public void CreateCharacter(Vector3 position) { CharacterBehaviour cb = AddCharacter((GameObject)Instantiate(character, transform.TransformPoint(position), character.transform.rotation)); cb.tribe = this; cb.transform.parent = transform; }
private void OnTriggerExit2D(Collider2D collision) { if (collision.gameObject.GetComponent <CharacterBehaviour>() != null) { character = null; } }
// Use this for initialization void Start() { Debug.Log("Level1: Wakes up!!"); mapObject = new GameObject("Map"); map = mapObject.AddComponent <Map>(); setColor = true; if (characterBeh == null || characterObject == null) { characterObject = Resources.Load("Prefabs/Character") as GameObject; characterBeh = (Instantiate(characterObject) as GameObject).GetComponent <CharacterBehaviour>(); } characterBeh.gameObject.transform.position = new Vector2(-3.5f, -1.5f); characterBeh.move(3, 3); //Randomly generate some collideable tiles for (int i = 0; i < 10; i++) { float randomX = Random.Range(0f, 10f); float randomY = Random.Range(0f, 10f); Tile t = map.getTile((int)randomX, (int)randomY); t.setCollideable(true); t.defaultColor = Color.green; map.setTileColor(t, Color.green); } characterBeh.setState(CharacterBehaviour.CharacterState.Selected); }
void Update() { if (!GameManager.instance.gameOver && !_player) { _player = GameManager.instance.player.GetComponent <CharacterBehaviour>(); } }
/// <summary> /// Sent when another object enters a trigger collider attached to this /// object (2D physics only). /// </summary> /// <param name="other">The other Collider2D involved in this collision.</param> void OnTriggerEnter2D(Collider2D other) { if (other.tag == charactersTag) { if (!characterInstance) { characterInstance = other.gameObject.GetComponent <CharacterBehaviour>(); } if (!upTriggerActivated && upTrigger.IsTouching(other)) { upTriggerActivated = true; } if (!downTriggerActivated && downTrigger.IsTouching(other)) { downTriggerActivated = true; } if (!leftTriggerActivated && leftTrigger.IsTouching(other)) { leftTriggerActivated = true; } if (!rightTriggerActivated && rightTrigger.IsTouching(other)) { rightTriggerActivated = true; } } }
void OnTriggerEnter(Collider other) { CharacterBehaviour cb = other.GetComponent <CharacterBehaviour> (); if (cb != null) { switch (buildingType) { case "hut": if (cb.CarriedResourceType().Equals("wood")) { tribe.StoreWood(cb.CarriedResourceAmount()); } else if (cb.CarriedResourceType().Equals("rock")) { tribe.StoreRock(cb.CarriedResourceAmount()); } else if (!cb.CarriedResourceType().Equals("")) { Debug.Log(other.name + " was carrying " + cb.CarriedResourceType() + ", which is unknown. (Is it not lowercase?)"); } cb.ResetCarrying(); break; case "barracks": if (!cb.GetJob().Equals("kill")) { string message = ""; if (tribe.GetResourceAmount("wood") < 5) { message += "Not enough wood! (" + tribe.GetResourceAmount("wood") + " / 5)"; } if (tribe.GetResourceAmount("rock") < 2) { message += "\nNot enough rocks! (" + tribe.GetResourceAmount("rock") + " / 2)"; } if (message.Equals("")) { SoundHandler.PlaySound("equip"); cb.SetJob("kill"); tribe.StoreWood(-5); tribe.StoreRock(-2); } else { HUDController.PostMessage(message, false); } } else { SoundHandler.PlaySound("dequip"); cb.SetJob(""); tribe.StoreWood(5); tribe.StoreRock(2); } break; } } }
protected virtual void Reset() { behaviour = GetComponent <CharacterBehaviour>(); health = maxHealth; movement.velocity.Set(0, 0, 0); movement.force.Set(0, 0, 0); }
protected override void ExecuteAction(CharacterBehaviour character) { if (character && !activated && character.CheckInventaryObjectOnSelectedPosition(activatorItemName)) { GameEvents.FSMEvents.StartInteraction.SafeInvoke(GameEnums.FSMInteractionEnum.ActivateItem); ActivateTree(); } }
protected override void ExecuteAction(CharacterBehaviour character) { if (active) { active = false; Biocrowds.Core.World.Instance.InvertFlow(); } }
// Use this for initialization void Start () { if (charBehaviour == null) { try { charBehaviour = GetComponent<CharacterBehaviour> (); } catch (Exception exc) { Debug.LogError ("No CharacterBehaviour script found in the " + gameObject.name + " object: " + exc); } } }
public void KillCharacter(CharacterBehaviour cb) { characters.Remove (cb); Destroy (cb.gameObject); }
void Start() { m_player = GameObject.FindGameObjectWithTag("Player"); m_character = m_player.GetComponent<CharacterBehaviour>(); m_characterPosition = m_character.transform.position; }
private void OnTriggerExit(Collider other) { m_interactingBehaviour = null; }
private void OnTriggerEnter(Collider other) { m_interactingBehaviour = other.GetComponent<CharacterBehaviour>(); }
void Start() { m_player = GameObject.FindGameObjectWithTag("Player"); m_character = m_player.GetComponent<CharacterBehaviour>(); }