void SpawnMinion(double pX, double pZ) { GameObject minion = Instantiate(prefabMinion, new Vector3((float)pX, 0.0f, (float)pZ), Quaternion.identity) as GameObject; MinionController controller = minion.GetComponent <MinionController>(); controller.Init(this.DeregisterMinion); }
private void Awake() { parMinCtrl = GetComponentInParent <MinionController>(); SphereCollider collider = GetComponent <SphereCollider>(); parGamObj = parMinCtrl.gameObject; }
public FleeState(FSM <MinionController.States> fsm, MinionController minionController) { _fsm = fsm; _minionController = minionController; originalHealCooldown = _minionController.originalHealCooldown; currentHealCooldown = originalHealCooldown; }
void Update() { if (Time.time - _LastSpawnTime > _SpawnTimerSeconds && _SpawnPoint != null) { // Using for loop because deletions will occur within loop for (int i = 0; i < _Minions.Count; ++i) { MinionController exitingMinion = _Minions[i]; // Check if it's destroyed if (exitingMinion == null) { _Minions.RemoveAt(i); --i; } } // If we haven't reached the max, respawn if (_Minions.Count < _MaxNumMinions) { Vector3 position = _SpawnPoint.position; position.z = -1; GameObject minion = Instantiate(_MinionPrefab, position, Quaternion.identity); MinionController controller = minion.GetComponent <MinionController>(); controller.PlayerTransform = _Player; controller.EnemyBaseTransform = _PlayerBase; _Minions.Add(controller); } _LastSpawnTime = Time.time; } }
private void MinionsSpawn() { GameObject newMinion = Instantiate(minion, spawnPoint.position, Quaternion.Euler(spawnPoint.transform.forward)) as GameObject; newMinion.transform.SetParent(minionsParent.transform); if (isWhite) // for white minions { newMinion.GetComponent <SpriteRenderer>().color = Color.white; newMinion.GetComponent <CharactersController>().isWhite = true; MinionController setNew = newMinion.GetComponent <MinionController>(); setNew.iconMap = whiteTargets; setNew.healthBar = Instantiate(minionHealthBar, newMinion.transform); } else // for black minions { Vector3 tempScale = new Vector3(-newMinion.transform.localScale.x, newMinion.transform.localScale.y, newMinion.transform.localScale.z); newMinion.transform.localScale = tempScale; newMinion.GetComponent <SpriteRenderer>().color = Color.black; newMinion.GetComponent <CharactersController>().isWhite = false; MinionController setNew = newMinion.GetComponent <MinionController>(); setNew.iconMap = blackTargets; setNew.healthBar = Instantiate(minionHealthBar, newMinion.transform); } }
public void RemoveMinion(MinionController minionController) { activeMinions.Remove(minionController); playerMoveGuide.RemoveSubPoint(); Destroy(minionController.gameObject); }
void Start() { respawnPoints = new LinkedList <GameObject>(); networkManager = GameObject.FindGameObjectWithTag("NetworkManager"); translate = Vector3.zero; teleportPosition = Vector3.zero; correctingFactorMove = 0.1f; correctingFactorSparkPoint = 0.7f; moveSparkPoint = false; speed = 5.0f; move = false; playerId = id; id += 1; //Debug.Log(playerId); respawnTimer = -1f; respawnPoint = null; needRespawn = false; minionController = GetComponent <MinionController>(); //minionController = (GameObject) Instantiate (minionController); //minionController.GetComponent<MinionController>().id = playerId; health = 20; }
//Bewegt Objekt zum Gegner und greift an wenn in Reichweite private void MoveAndAttack() { if (targetedEnemy == null) { return; } //Setzt Ziel des NavMeshAgents auf die position des angewählten Gegners navMeshAgent.destination = targetedEnemy.position; //Setzt walking auf true, wenn die Distanz, die der NavMeshAgent noch gehen muss größer ist als die Angriffsreichweite des Objekts. if (navMeshAgent.remainingDistance >= attackDistance) { navMeshAgent.isStopped = false; } // Greift an, wenn die Distanz, die der NavMeshAgent noch gehen muss kleiner ist, als die Angrifftsreichweite des Objekts. if (navMeshAgent.remainingDistance <= attackDistance) { transform.LookAt(targetedEnemy); //Schaut zum Gegner //Vector3 dirToShoot = targetedEnemy.transform.position - transform.position; //Setzt die Richtung wohin geschossen wird. minion = targetedEnemy.GetComponent <MinionController>(); if (Time.time > nextAttack) { nextAttack = Time.time + attackRate; //Greift den Gegner an. minion.hp -= attackDamage; Debug.Log("Gegner wird angegriffen!"); } navMeshAgent.isStopped = true; } }
// TODO : Board positioning public void SummonMinion(MinionCard minionCard, int position) { Debugger.LogPlayer(this, "summoning " + minionCard.Name + " at position " + position); if (Minions.Count < 7) { // Creating a Minion and its Controller Minion minion = new Minion(minionCard); minion.Controller = MinionController.Create(BoardController, minion); // Adding the Minion to the Player Minion list Minions.Add(minion); // Adding the Minion to the BoardController BoardController.AddMinion(minion, position); // Firing summoned events EventManager.Instance.OnMinionSummon(this, minion); } else { Debugger.LogPlayer(this, "couldn't summon " + minionCard.Name + " because board is full"); } // Updating the Player glows UpdateSprites(); }
public FlockState(FSM <MinionController.States> fsm, MinionController minionController, FlockingEntity flockingEntity) { _fsm = fsm; _minionController = minionController; _flockingEntity = flockingEntity; _avoid = new Avoid(_minionController.transform, _minionController.lineOfSight.obstaclesLayer, _minionController.obstacleRadius, _minionController.obstacleWeight); } // Constructor del Estado Flock.
// Update is called once per frame void Update() { if (Time.time > spawnMinionNext + MINION_SPAWN_RATE) { spawnMinionNext = Time.time + MINION_SPAWN_RATE; unitGameObject = (GameObject)Network.Instantiate(spawnUnit, transform.position, transform.rotation, 0); unitController = unitGameObject.GetComponent<MinionController>(); unitController.SetMinionLane(minionLane); unitController.Initialize(); } }
public void MinionsPlayerFollowing() { _attack = false; foreach (var minion in Minions) { MinionController mc = minion.GetComponent <MinionController>(); mc.CurrentState = State.FOLLOWING; } }
public void MinionsBerserkMode() { _attack = false; foreach (var minion in Minions) { MinionController mc = minion.GetComponent <MinionController>(); mc.CurrentState = State.BERSERK; } }
public void CollisionProcess(MinionController otherMc) { Hp -= otherMc.Attack; if (Hp <= 0) { Destroy(gameObject); } transform.Translate(IsEnemy ? _rightVector * otherMc.KnockBack * 10 : _leftVector * otherMc.KnockBack * 10); }
// OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { if (minion == null) { minion = (MinionController)animator.GetComponentInParent <MinionController>(); animator.SetBool("spawnCooldown", minion.isInSpawnCooldown); return; } animator.SetBool("spawnCooldown", minion.isInSpawnCooldown); target = minion.checkForPlayer(); }
public void AddMinionToList(MinionController mc) { switch (mc.Team) { case MinionTeamsEnum.Blue: blueMinions.Add(mc); break; case MinionTeamsEnum.Red: redMinions.Add(mc); break; } }
public SearchState(FSM <MinionController.States> fsm, MinionController minionController) { _fsm = fsm; _minionController = minionController; _transform = minionController.transform; _nodes = GameManager.Instance.nodesList; _minionsList = minionController.allyMinionsList; if (minionController.isBoss == true) { _avoid = new Avoid(_minionController.transform, _minionController.lineOfSight.obstaclesLayer, _minionController.obstacleRadius, _minionController.obstacleWeight); } }
void OnTriggerEnter2D(Collider2D other) { if (other.gameObject.tag == "Minion" && target == null) { target = other.gameObject; MC = other.gameObject.GetComponent <MinionController>(); Targeting(); } if (other.gameObject.tag == "Angel" && target == null) { target = other.gameObject; AC = other.gameObject.GetComponent <AngelController>(); Targeting(); } }
public void RemoveMinionFromList(MinionController mc) { switch (mc.Team) { case MinionTeamsEnum.Blue: blueMinions.Remove(mc); break; case MinionTeamsEnum.Red: redMinions.Remove(mc); break; } OnMinionsNumberChanged?.Invoke(); if (redMinions.Count == 0 || blueMinions.Count == 0) { SimulationController.OnFinishSimulation?.Invoke(); } }
/// <summary> /// Spawns a Minion at the first available spawnpoint if one is available from /// the object pool. Minions will not spawn if there are no open spawnpoints, or /// there are no available minions. I.e. the object pool request fails. /// </summary> public void SpawnMinion() { Transform spawnpoint = GetOpenSpawn(); if (spawnpoint) { MinionController minion = minionPool.Request(spawnpoint); if (minion) { } else { //Debug.Log("Maximum allowed minions reached. Skipping Minion spawn."); } } else { //Debug.Log("No open spawnpoints. Skipping Minion spawn."); } }
private void Attack() { //Gibt es kein Ziel, wird auch nicht angegriffen. if (target == null) { return; } else { transform.LookAt(target); minion = target.GetComponent <MinionController>(); if (Time.time > nextAttack) { nextAttack = Time.time + attackRate; //Greift den Gegner an. minion.hp -= attackDamage; //Debug.Log("Gegner wird angegriffen!"); } navMeshAgent.isStopped = true; } }
void CmdSpawnMinion(int mTeam) { var minion = (GameObject)Instantiate( minionPrefab, new Vector3(Random.Range(-3f, 3f), 9, (mTeam * 2 - 1) * 110 + Random.Range(-1f, 1f)), Quaternion.identity); MinionController minionController = minion.GetComponent <MinionController>(); minionController.team = mTeam; minionController.baseLocation = new Vector3(0, 9, (mTeam * 2 - 1) * 110); if (mTeam == 0) { minion.GetComponent <MeshRenderer>().material.color = Color.red; } else { minion.GetComponent <MeshRenderer>().material.color = Color.blue; } NetworkServer.Spawn(minion); minion.GetComponent <NetworkIdentity>().AssignClientAuthority(connectionToClient); }
public override void Awake() { Debug.Log("Pursuit State Awake"); if (_minionController.IsBossAlive() == false) { _enemyController = _minionController.SelectRandomEnemy(); _enemyTransform = _enemyController.transform; } _enemyTransform = _minionController.currentEnemy; if (_enemyTransform == null || _enemyController == null) { _enemyController = _minionController.SelectRandomEnemy(); _enemyTransform = _enemyController.transform; } _enemyController = _enemyTransform.GetComponent <MinionController>(); avoid = new Avoid(_minionController.transform, _minionController.lineOfSight.obstaclesLayer, _minionController.obstacleRadius, _minionController.obstacleWeight); avoid.SetTarget(_enemyTransform); }
void OnCollisionEnter(Collision collision) { if (Network.isServer) { if (collision.gameObject.tag == "Player" && collision.gameObject.GetComponent <Player>().getPlayerId() != minionId) { collision.gameObject.networkView.RPC("ApplyDamage", RPCMode.AllBuffered, 2); GameObject[] players = GameObject.FindGameObjectsWithTag("Player"); foreach (GameObject p in players) { MinionController mc = p.GetComponent <MinionController>(); if (mc.id == minionId) { mc.networkView.RPC("MinusMinion", RPCMode.AllBuffered); break; } } Network.Destroy(GetComponent <NetworkView>().viewID); } } }
private void Update() { if (_attack) { if (Input.GetMouseButtonDown(0)) { RaycastHit hit; Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out hit)) { foreach (var minion in Minions) { MinionController mc = minion.GetComponent <MinionController>(); mc.CheckPoint = hit.point; mc.CurrentState = State.ATTACKING; } } StartCoroutine("DisableControlling"); } } }
// TODO : Frozen, Silenced, DivineShield, Taunt, etc... renderers/overlays public static MinionController Create(BoardController parentBoard, Minion minion) { // Creating a new GameObject to hold all the components GameObject minionObject = new GameObject(minion.Card.Name); minionObject.transform.ChangeParent(parentBoard.transform); // Adding a BoxCollider to the GameObject BoxCollider collider = minionObject.AddComponent <BoxCollider>(); collider.size = new Vector3(2.5f, 3.5f, 0.5f); // Adding a MinionController to the GameObject MinionController minionController = minionObject.AddComponent <MinionController>(); minionController.Minion = minion; minionController.Collider = collider; // Initializing the MinionController minionController.Initialize(); return(minionController); }
public void DealDamage(GameObject minion, int damage, bool applyBurn, bool applySlow) { if (damage == 0) { damage = this.attackDamage; } MinionController minionController = minion.GetComponent <MinionController>(); minionController.ReceiveDamage(damage); minionController.SimpleKnockBack(this.knockbackForce); if (applyBurn) { (int damage, float rate, int ticks)passive = GameObject.FindGameObjectWithTag("FireGem").GetComponent <FireUpgrade>().GetPassiveParameters(); minionController.ApplyBurn(passive.damage, passive.rate, passive.ticks); } if (applySlow) { (float slow, float duration)passive = GameObject.FindGameObjectWithTag("IceGem").GetComponent <IceUpgrade>().GetPassiveParameters(); minionController.ApplySlow(passive.slow, passive.duration); } }
public void PlayMinion(MinionCard minionCard, int position) { Debugger.LogPlayer(this, "playing " + minionCard.Name + " at position " + position); // Creating a Minion and its Controller Minion minion = new Minion(minionCard); minion.Controller = MinionController.Create(BoardController, minion); // Adding the Minion to the Player Minion list Minions.Add(minion); // Adding the Minion to the BoardController BoardController.AddMinion(minion, position); // Firing OnPlayed and OnSummoned events minion.Buffs.Battlecry.OnNext(null); EventManager.Instance.OnMinionPlayed(this, minion); EventManager.Instance.OnMinionSummon(this, minion); // Updating the Player glows UpdateSprites(); }
// Start is called before the first frame update void Start() { minionController = GetComponent <MinionController>(); animator = GetComponent <Animator>(); }
void Awake() { minCtrlScrpt = GetComponent<MinionController>(); animator = GetComponent<RpcNetworkAnimator>(); container = transform.Find("Rotation"); path = new List<Vector2>(); isStunned = false; slowDownMod = 1.0f; // Gets slowed UI and disables it. if (SlowedUI == null) { SlowedUI = transform.GetChild(1).gameObject; if (SlowedUI == null) { Debug.Log(this.gameObject + " did not find its SLOWED UI"); } // Deactivate Slowed UI minCtrlScrpt.RpcSetSlowedUiActive(false); } }
void Start() { minionController = GetComponentInParent <MinionController>(); gameManager = FindObjectOfType <GameManager>(); }
// Update is called once per frame void Update() { if (!isLocalPlayer) { return; } selected.RemoveAll(item => item == null); float deltaZoom = Input.GetAxis("Mouse ScrollWheel"); cameraHeight -= deltaZoom * zoomSpeed; cameraHeight = Mathf.Clamp(cameraHeight, minHeight, maxHeight); transform.position = new Vector3(transform.position.x, cameraHeight, transform.position.z); if (Input.GetMouseButton(2)) { float mouseX = Input.GetAxis("Mouse X"); float mouseY = Input.GetAxis("Mouse Y"); transform.Translate(new Vector3(mouseY, 0, -mouseX)); } else if (edgeCam) { float mouseX = Input.GetAxis("Mouse X"); float mouseY = Input.GetAxis("Mouse Y"); if (Input.mousePosition.x <= 10 && mouseX < 0) { transform.Translate(new Vector3(0, 0, mouseX * 0.5f)); } if (Input.mousePosition.x >= Screen.width - 10 && mouseX > 0) { transform.Translate(new Vector3(0, 0, mouseX * 0.5f)); } if (Input.mousePosition.y <= 10 & mouseY < 0) { transform.Translate(new Vector3(-mouseY * 0.5f, 0, 0)); } if (Input.mousePosition.y >= Screen.height - 10 & mouseY > 0) { transform.Translate(new Vector3(-mouseY * 0.5f, 0, 0)); } } if (Input.GetMouseButton(0)) { if (mouseDown == false) { selectionPanel = Instantiate(selectionPrefab, Input.mousePosition, Quaternion.identity, canvas.transform); selectionPanel.transform.SetAsFirstSibling(); selectionPanel.transform.localScale = new Vector3(0, 0, 1); selectionPanel.transform.position = Input.mousePosition; selectionStart = Input.mousePosition; mouseDown = true; foreach (GameObject minion in selected) { minion.GetComponent <MeshRenderer>().material.color = new Color((1 - team), 0f, team, 1); } selected.Clear(); } else { selectionPanel.transform.localScale = new Vector3(Input.mousePosition.x - selectionStart.x, Input.mousePosition.y - selectionStart.y, 0) / 1000; selectionPanel.transform.position = (Input.mousePosition + selectionStart) / 2; } } else { if (mouseDown == true) { GameObject[] minions = GameObject.FindGameObjectsWithTag("Minion"); Ray ray = GetComponentInChildren <Camera>().ScreenPointToRay(selectionStart); RaycastHit hit; if (Physics.Raycast(ray, out hit, 100, movementMask)) { Ray ray2 = GetComponentInChildren <Camera>().ScreenPointToRay(Input.mousePosition); RaycastHit hit2; if (Physics.Raycast(ray2, out hit2, 100, movementMask)) { foreach (GameObject minion in minions) { if (Mathf.Min(hit.point.x, hit2.point.x) < minion.transform.position.x && Mathf.Max(hit.point.x, hit2.point.x) > minion.transform.position.x && Mathf.Min(hit.point.z, hit2.point.z) < minion.transform.position.z && Mathf.Max(hit.point.z, hit2.point.z) > minion.transform.position.z && ((minion.GetComponent <MinionController>() != null && minion.GetComponent <MinionController>().team == team) || (minion.GetComponent <FighterController>() != null && minion.GetComponent <FighterController>().team == team))) { selected.Add(minion); minion.GetComponent <MeshRenderer>().material.color = new Color(0.3f * (1 - team), 0f, 0.3f * team, 1); } } } } Destroy(selectionPanel); mouseDown = false; } } if (Input.GetMouseButtonDown(1)) { GameObject[] minions = GameObject.FindGameObjectsWithTag("Minion"); foreach (GameObject minion in selected) { if (minion.GetComponent <MinionController>() != null) { MinionController minionController = minion.GetComponent <MinionController>(); if (minionController.team == team) { Ray ray = GetComponentInChildren <Camera>().ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(ray, out hit, 100, resourceMask)) { Debug.Log("Hit resource"); minionController.SetTarget(hit.collider.name, hit.point, hit.collider.transform.gameObject); minionController.mode = 1; minionController.commander = this; minion.GetComponent <NavMeshAgent>().SetDestination(hit.point); } else if (Physics.Raycast(ray, out hit, 100, movementMask)) { Debug.Log(hit.point); minionController.SetTarget("", hit.point, null); minion.GetComponent <NavMeshAgent>().SetDestination(hit.point); minionController.mode = 1; } } } if (minion.GetComponent <FighterController>() != null) { FighterController fighterController = minion.GetComponent <FighterController>(); if (fighterController.team == team) { Ray ray = GetComponentInChildren <Camera>().ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(ray, out hit, 100, attackMask)) { Debug.Log("Hit attackable"); fighterController.SetTarget(hit.collider.name, hit.point, hit.collider.transform.gameObject); fighterController.mode = 2; fighterController.attackMinions = false; fighterController.attackPlayers = false; fighterController.commander = this; // change this / may not be needed minion.GetComponent <NavMeshAgent>().SetDestination(hit.point); } else if (Physics.Raycast(ray, out hit, 100, movementMask)) { Debug.Log(hit.point); fighterController.SetTarget("", hit.point, null); minion.GetComponent <NavMeshAgent>().SetDestination(hit.point); fighterController.mode = 1; fighterController.attackMinions = false; fighterController.attackPlayers = false; } } } } } // attack minions if (Input.GetKeyDown(KeyCode.A)) { GameObject[] minions = GameObject.FindGameObjectsWithTag("Minion"); foreach (GameObject minion in selected) { if (minion.GetComponent <FighterController>() != null) { FighterController fighterController = minion.GetComponent <FighterController>(); if (fighterController.team == team) { fighterController.mode = 3; fighterController.attackMinions = true; fighterController.attackPlayers = false; } } } } // attack players if (Input.GetKeyDown(KeyCode.S)) { GameObject[] minions = GameObject.FindGameObjectsWithTag("Minion"); foreach (GameObject minion in selected) { if (minion.GetComponent <FighterController>() != null) { FighterController fighterController = minion.GetComponent <FighterController>(); if (fighterController.team == team) { fighterController.mode = 4; fighterController.attackMinions = false; fighterController.attackPlayers = true; } } } } if (Input.GetKeyDown("1")) { SpawnMinion(); } if (Input.GetKeyDown("2")) { SpawnFighter(); } // player health if (Input.GetKeyDown("3")) { UpgradeHealth(); } // speed if (Input.GetKeyDown("4")) { UpgradeSpeed(); } // damage against base if (Input.GetKeyDown("5")) { UpgradeDamage(); } // heal base if (Input.GetKeyDown("6")) { RepairBase(); } }
void Start() { happinessMeter = GameObject.Find("HappinessSlider").GetComponent<Slider>(); mc = GameObject.Find("MinionSpawnpoints").GetComponent<MinionController>(); anim = GetComponent<Animator>(); }