public void Activate(LemmingStateController lemming) { if (lemming == parentLemming) { particles.Play(); } }
private void LemmingDie(LemmingStateController lemming) { if (isServer) { RpcLemmingDie(lemming.GetComponent <NetworkIdentity>()); } }
//Assign Skills public bool assignSkill(LemmingStateController lemming) { if (skillsCounter[selectedSkill] <= 0) { return(false); } if (selectedSkill == Skill.Blocker) { blockerSelector.AttachToSomeone(lemming); isWaitingForBlockerConfirmation = true; return(false); } var localNetworkPlayer = LNetworkPlayer.LocalInstance; if (localNetworkPlayer == null) { Debug.LogError("no netowrk player"); return(false); } localNetworkPlayer.CmdGiveSkill(lemming.GetComponent <NetworkIdentity>(), selectedSkill, lemming.transform.position); /* todo: give skill used to return false when trying to give skills and failed. * With networked game, we need to change it to create skill given and skill failed events. */ skillsCounter[selectedSkill]--; selectedSkill = Skill.None; GameEvents.Lemmings.LemmingUsedSkill.SafeInvoke(lemming); return(true); }
//Update Display Variables private void UpdateInfo(LemmingStateController lemming = null) { updateState(SkillsController.Instance.selectedSkill != Skill.None); int skillCount = SkillsController.Instance.getRemainingUses(skill); skillCountText.text = skillCount.ToString(); toggleButton.interactable = skillCount > 0; }
private void LemmingExit(LemmingStateController lemming) { Debug.Log("triggered local lemming exit"); if (isServer) { Debug.Log("server triggered local lemming exit"); RpcLemmingExit(lemming.GetComponent <NetworkIdentity>()); } }
private void Awake() { lemmingAnimationController = GetComponent <LemmingAnimationController>(); movementController = GetComponent <LemmingMovementController>(); movementController.OnArrived += OnArrivetAtWaypoint; movementController.OnGetNextWaypoint += OnGetNextWaypoint; stateController = GetComponent <LemmingStateController>(); SetupStateMachine(); }
private void RpcLemmingEnter(NetworkIdentity lemmingID) { if (lobbyPlayer.playerNum != LevelController.Instance.team) { return; } LemmingStateController lemming_ = lemmingID.GetComponent <LemmingStateController>(); lemmingsOnScene[lemming_.Team].Add(lemming_); lemmingsSpawned[lemming_.Team]++; GameEvents.NetworkLemmings.LemmingSpawned.SafeInvoke(lemming_); }
private void UpdateInfo(LemmingStateController lemming) { if (LevelController.Instance.gameStateManager == null) { return; } outCount = LevelController.Instance.gameStateManager.lemmingsSpawned[LevelController.Instance.team]; inCount = LevelController.Instance.gameStateManager.lemmingsEnteredExit[LevelController.Instance.team]; outText.text = outCount.ToString(); inText.text = outCount == 0 ? "0%" : (((int)(((float)inCount / (float)outCount) * 100)).ToString() + "%"); }
private void RpcLemmingDie(NetworkIdentity lemmingID) { if (lobbyPlayer.playerNum != LevelController.Instance.team) { return; } LemmingStateController lemming_ = lemmingID.GetComponent <LemmingStateController>(); lemmingsOnScene[lemming_.Team].Remove(lemming_); lemmingsDied[lemming_.Team]++; GameEvents.NetworkLemmings.LemmingDied.SafeInvoke(lemming_); lemmingID.GetComponent <LemmingActions>().EliminateLemming(); }
private void Start() { //Initialize Variables targetPositionAddress = Vector3Int.RoundToInt(transform.position); nextWaypoint = this.transform.position; lemmingActions = GetComponent <LemmingActions>(); wallsLayerMask = LayerMask.GetMask("Wall"); lemmingsActionLayerMask = LayerMask.GetMask("LemmingAction"); exitLayerMask = LayerMask.GetMask("Exit"); lemmingStateController = GetComponent <LemmingStateController>(); raycastHits = new RaycastHit[1]; overlapSphereHits = new Collider[1]; fallingBlocksCount = 0; }
private void UpdateBar(LemmingStateController lemming) { var dict = LevelController.Instance.gameStateManager.lemmingsEnteredExit; int count = dict[team]; for (int i = 0; i < count; i++) { if (!units[units.Count - i - 1].on) { fill = count; UpdateFill(count); } } }
void RaycastForHighlightable() { if (EventSystem.current.IsPointerOverGameObject()) { HighlightOff(); return; } Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); Collider[] colliders = Physics.OverlapCapsule(ray.origin, ray.origin + ray.direction * distance, radius, highlaytableLayers, QueryTriggerInteraction.Collide); float distanceFromRay = float.MaxValue; bool highlighted = false; foreach (Collider col in colliders) { HighlightableObject highlightScript = col.gameObject.GetComponentInParent <HighlightableObject>(); if (highlightScript != null && highlightScript.canBeHighlighted) { LemmingStateController lemming = highlightScript.GetComponent <LemmingStateController>(); if (lemming != null) { if (lemming.Team != playerTeam) { continue; } } float angle = Vector3.Angle(ray.direction, (col.bounds.center - Camera.main.transform.position)); float dist = Mathf.Sin(Mathf.Deg2Rad * angle) * Vector3.Distance(col.bounds.center, Camera.main.transform.position); if (dist < distanceFromRay) { distanceFromRay = distance; highlightedObject = highlightScript; highlighted = true; } } } if (highlighted && !isHighlighting) { HighlightOn(); } else if (!highlighted && isHighlighting) { HighlightOff(); } }
private void RpcLemmingExit(NetworkIdentity lemmingID) { if (lobbyPlayer.playerNum != LevelController.Instance.team) { return; } LemmingStateController lemming_ = lemmingID.GetComponent <LemmingStateController>(); if (!lemmingsOnScene.ContainsKey(lemming_.Team)) { lemmingsOnScene.Add(lemming_.Team, new List <LemmingStateController>()); } lemmingsOnScene[lemming_.Team].Remove(lemming_); lemmingsEnteredExit[lemming_.Team]++; GameEvents.NetworkLemmings.LemmingReachedExit.SafeInvoke(lemming_); }
//Create Lemming private GameObject createLemming(LemmingSpawnInfo info) { GameObject obj = Instantiate(spawnable, info.position, Quaternion.identity); LemmingMovementController movController = obj.GetComponent <LemmingMovementController>(); if (movController != null) { movController.SetDirection(info.startingMovementDirection); movController.SetForwardDirection(info.startingMovementDirection); } LemmingStateController stateController = obj.GetComponent <LemmingStateController>(); if (stateController != null) { stateController.Team = info.team; } return(obj); }
public Direction CheckChangeDirectionOrders() { int hits = Physics.OverlapSphereNonAlloc(targetPositionAddress, 0.5f, overlapSphereHits, lemmingsActionLayerMask); for (int i = 0; i < hits; i++) { var hit = overlapSphereHits[i]; LemmingStateController otherLemmingStateController = hit.GetComponentInParent <LemmingStateController>(); if (otherLemmingStateController != null) { if (otherLemmingStateController.checkIsBlocker()) { var direction = otherLemmingStateController.BlockingDirection; return(direction); } } } return(Direction.None); }
// Update is called once per frame void Update() { if (Input.GetMouseButtonDown(0)) { // if has any selected skill if (SkillsController.Instance.selectedSkill != Skill.None) { if (SkillsController.Instance.isWaitingForBlockerConfirmation) { if (!SkillsController.Instance.blockerSelector.someButtonHighlighted) { //Cancel Directioner SkillsController.Instance.cancelSkill(); return; } } else { if (!HighlightPointer.Instance.isHighlighting) { SkillsController.Instance.cancelSkill(); return; } } if (!SkillsController.Instance.isWaitingForBlockerConfirmation) { if (HighlightPointer.Instance.isHighlighting) { LemmingStateController lemming = HighlightPointer.Instance.highlightedObject.GetComponent <LemmingStateController>(); SkillsController.Instance.assignSkill(lemming); } } } } }
private void PlaySFX_LemmingDie(LemmingStateController lemming) { playSFX(lemmingDie.GetUniqueRandom()); }
public void AttachToSomeone(LemmingStateController following) { followingLemming = following; Show(); }
public void Detach() { followingLemming = null; Hide(); }
private void Awake() { highlightableScript = GetComponent <HighlightableObject>(); lemmingAIScript = GetComponent <LemmingStateController>(); }
void Awake() { particles = GetComponent <ParticleSystem>(); parentLemming = GetComponentInParent <LemmingStateController>(); }
private void PlaySFX_GiveSkill(LemmingStateController lemming) { playSFX(giveSkill); }