public Wizard(AbstractUnit body) : base(body) { basisSpeed = 0.5f; basisAttack = 4f; basisDefense = 1; //upgrades.Add(EntityType.something); }
public override bool Interract(bool isRemoted, AbstractUnit target, Vector3 positionTarget) { deltaTime += UnitLibData.deltaTime; bool result = false; if (body.isMoving) { result = Move(isRemoted, target, positionTarget); } if (deltaTime >= TickAttack) { if (target == null) { return(result); } if (Vector3.Distance(body.GetPosition(), target.GetPosition()) <= 3) { if (!_playingSound) { GameSingleton.Instance.soundManager.Play("Slash"); } body.Attack(target, GetAttackUnit(target)); } deltaTime -= TickAttack; } return(result); }
public void Move(AbstractUnit unit, HexCoord target) { unit.Move(target); foreach (var enemy in enemies) { var distance = unit.Coord.WorldDistance(enemy.Coord); var shooted = distance < (enemy.AttackRadius + 0.1f); if (shooted) { if (unit is Airplane && enemy is AntiAir && enemy.ResistanceCurrent > 0) { unit.IsDead = true; enemy.Shooting(); playerArmy.Remove(unit); break; } else if (unit is Soldier && enemy is Bunker && enemy.ResistanceCurrent > 0) { unit.IsDead = true; enemy.Shooting(); playerArmy.Remove(unit); break; } } } Debug.Log("Army " + playerArmy.Count); UpdateControl(); CheckEnd(); }
public Sniper(AbstractUnit body) : base(body) { MultiplierScore = 4f; tickAttack /= 4; basisAttack *= 4; accuracy = int.MaxValue; }
public void updateStatus(AbstractUnit unit) { CheckCollision(out var left, out var right, unit); // Debug.LogError($"{left.collider}, {right.collider}"); var canMove = left.collider == null && right.collider == null; if (left.collider != null && leftA) { unit.transform.Rotate(Vector3.forward * deltaAngle * -1 * Time.deltaTime); //Debug.Log("left"); } else if (right.collider != null && rightA) { unit.transform.Rotate(Vector3.forward * deltaAngle * Time.deltaTime); //Debug.Log("right"); } else if (left.collider && right.collider) { //Debug.Log(("both")); // unit.transform.Rotate(Vector3.up * player.transform.position.y * deltaAngle * Time.deltaTime); } if (canMove) { unit.transform.Translate(unit.transform.up * Time.deltaTime * 1f, Space.World); } }
// Start is called before the first frame update void Start() { levelController = GameObject.Find("LevelController").GetComponent <LevelController>(); currentUnit = levelController.playerUnits[this.selectedUnit]; actionButton.onClick.AddListener(this.ActionButtonClicked); nextRoundButton.onClick.AddListener(this.NextRoundButtonClicked); }
// Update is called once per frame void Update() { if (levelController.playerUnits.Count > levelController.currentlySelectedUnit && levelController.currentlySelectedUnit != -1) { currentUnit = levelController.playerUnits[levelController.currentlySelectedUnit]; } else { Debug.Log("All units dead. Can't show anything"); actionPointsTextField.GetComponent <UnityEngine.UI.Text>().text = ""; nameTextField.GetComponent <UnityEngine.UI.Text>().text = ""; specialMoveTextField.GetComponent <UnityEngine.UI.Text>().text = ""; return; } Transform unitTransform = currentUnit.ObjectTransform; portraitCamera.GetComponent <PortraitCameraController>().Show(unitTransform); actionPointsTextField.GetComponent <UnityEngine.UI.Text>().text = currentUnit.ActionPoints.ToString() + " / " + (int)currentUnit.UnitType; nameTextField.GetComponent <UnityEngine.UI.Text>().text = currentUnit.name.ToString(); specialMoveTextField.GetComponent <UnityEngine.UI.Text>().text = string.Format("Cost: {0} Action Points\n\n{1}", currentUnit.UnitActions?[0].Item2, currentUnit.UnitActions?[0].Item3); }
public override bool Interract(bool isRemoted, AbstractUnit target, Vector3 positionTarget) { deltaTime += UnitLibData.deltaTime; bool result = false; if (body.isMoving) { result = Move(isRemoted, target, positionTarget); } if (_canShoot && deltaTime >= TickAttack) { GameSingleton.Instance.soundManager.Play("MageAttack"); for (int i = 0; i < 9; i++) { body.Attack(target, GetAttackUnit(target)); } deltaTime -= TickAttack; } return(result); }
public void ActivateNextUnitAction(bool isFirstActionInPhase) { if (!isFirstActionInPhase) { ActionPhaseSortedUnitsList.First().IsActivated = false; ActionPhaseSortedUnitsList.Remove(ActionPhaseSortedUnitsList.First()); } if (ActionPhaseSortedUnitsList.Any()) { ActiveUnit = ActionPhaseSortedUnitsList.First(); } else { //no more units left for action, reset unit movepoints and change phase. this.Round += 1; foreach (var pl in Players) { pl.PlayerUnits.ForEach(u => u.MovePointsLeft = u.BaseMoves); } StartMovementPhase(); return; } ActiveUnit.IsActivated = true; //syncvar hook will tell client that unit is active. RoundTimer = DefaultRoundTime; }
private Vector2 requestDirectionPlayer(AbstractUnit currentUnit) { var pos = currentUnit.transform.position; var playerPos = player.transform.position; var dir = playerPos - pos; return(dir); }
public Archer(AbstractUnit body) : base(body) { basisSpeed = 0.5f; basisAttack = 2f; basisDefense = 2f; accuracy = 0.5f; tickAttack = 2f; }
public virtual void Move(AbstractUnit unit, int x, int y) { this.unit = unit; startx = unit.Position.X; starty = unit.Position.Y; t.Start(); unit.State = State.MOVING; finalx = x; finaly = y; }
public override void UseAbility(AbstractUnit unit) { base.UseAbility(unit); unit.RecieveDamage(getDmg(0)); Stun s = new Stun(unit, 1, 90); s.TurnOn(host.MOD.apply_stun_chance, unit.MOD.ResistBleed); unit.buffs.Add(s); }
protected float GetAttackUnit(AbstractUnit target) { Effect effect = target.GetEffect(1); //defense //EquipmentEffect equipmentEffect = body.GetEquipmentEffect(1); int bonusLevel = effect.IdEffect == -1 ? 1 : effect.LevelEffect + 1; //int bonusEquipmentLevel = equipmentEffect.IdEffect == -1 ? 1 : equipmentEffect.LevelEffect; return(basisAttack / (bonusLevel * target.brain.basisDefense));// + bonusEquipmentLevel; }
private GameObject GetPrefab(AbstractUnit unit) { if (unit is Soldier) { return(soldier); } if (unit is Airplane) { return(airplane); } return(null); }
public void SetUnitUI(AbstractUnit unit) { if (!UiUnitPanel.activeInHierarchy) { UiUnitPanel.SetActive(true); } UiHpValue.text = unit.HPLeft.ToString(); UiMoveValue.text = unit.MovePointsLeft.ToString(); UiInitiativeValue.text = unit.BaseInitiative.ToString(); UiSightRangeValue.text = unit.BaseSightRange.ToString(); UiDmgValue.text = unit.BaseDamage.ToString(); UiHitChanceValue.text = (unit.BaseHitChance * 100).ToString() + "%"; }
public void startBossFight() { bossUnit = GameObject.FindGameObjectWithTag("Boss").GetComponent <AbstractUnit>(); bossCanvas.SetActive(true); timer.gameObject.SetActive(false); switch (Utility.level) { case 1: FindObjectOfType <AudioController>().changeTrack("snd_floor1_boss", true); bossCanvas.GetComponentInChildren <Text>().text = "M U T A N T C R A W K L E R"; return; case 2: FindObjectOfType <AudioController>().changeTrack("snd_floor2_boss", true); bossCanvas.GetComponentInChildren <Text>().text = "T H E F O R G O T T E N"; return; case 3: FindObjectOfType <AudioController>().changeTrack("snd_floor3_boss", true); bossCanvas.GetComponentInChildren <Text>().text = "C H R O M O K E R"; return; } }
private void TrainUnit(AbstractTrainCapability trainCapability, AbstractUnit unit = null) { var newunit = trainCapability.Train(unit); if (unit == null) { AddUnit(newunit); } else { RemoveUnit(unit); Units.Add(newunit); Buildables[unit.Id] = newunit; } }
public void RemoveEnemy(AbstractUnit abstractUnit) { AliveEnemies.Remove(abstractUnit); if (AliveEnemies.IsEmpty()) { gameState.OnPlayerWinLvl?.Invoke(); if (SceneManager.GetActiveScene().buildIndex + 1 != SceneManager.sceneCountInBuildSettings) { StartCoroutine(levelLoader.LoadScene(SceneManager.GetActiveScene().buildIndex + 1, cashedPlayer)); } else { return; } } }
private bool Move(bool isRemoted, AbstractUnit target, Vector3 positionTarget) { if (!isRemoted && target == null) { return(false); } int ind = 0; if (!isRemoted) { Entity entityTarget = GetFirstLivingEntity(); if (entityTarget == null) { return(false); } if (Vector3.Distance(entityTarget.transform.position, target.GetPosition()) <= 2.0f) { Vector3 destination = TerrainGrid.Instance.GetClosestValidPosition(entityTarget.transform.position); if (destination.x > -0.1f) // if < 0 not valid { LockPosition(destination); } } } bool isOnDest = false; for (int x = -1; x <= 1; x++) { for (int y = -1; y <= 1; y++) { if (body.entities[ind] != null) { Vector3 position = positionTarget + Vector3.right * x + Vector3.forward * y; if (body.entities[ind].aStarEntity.MoveTo(position, GameSingleton.Instance.aStarHandler, GetVitessUnit())) { body.SetPosition(positionTarget); isOnDest = true; } } ind++; } } return(isOnDest); }
public void OnMouseEnter() { if (_uiActivated) { return; } _unitNameBox.SetActive(true); AbstractUnit unit = GetComponent <AbstractUnit>(); _icon.sprite = GameSingleton.Instance.entityTypeToSprite.GetEntitySprite(unit.GetEntityType()); var unitType = unit.GetType(); _unitNameText.color = unitType == typeof(AiUnit) ? _red : _green; _unitNameText.SetText(unit.GetEntityType().ToString()); _isTouchingUnit = true; }
private GameObject GetPrefab(AbstractUnit unit) { if (unit is AntiAir) { return(antiAir); } if (unit is Bunker) { return(bunker); } if (unit is House) { return(house); } if (unit is Warehouse) { return(warehouse); } return(null); }
public void ActivateNextUnitMovement(bool isFirstMoveInPhase) { if (!isFirstMoveInPhase) { MovementPhaseSortedUnitsList.First().IsActivated = false; MovementPhaseSortedUnitsList.Remove(MovementPhaseSortedUnitsList.First()); } if (MovementPhaseSortedUnitsList.Any()) { ActiveUnit = MovementPhaseSortedUnitsList.First(); } else { //no more units left to move, start action phase. StartActionPhase(); return; } ActiveUnit.IsActivated = true; //syncvar hook will tell client that unit is active. RoundTimer = DefaultRoundTime; }
private void WorldView_MouseClick(object sender, MouseEventArgs e) { int x = e.X / _res; int y = e.Y / _res; if (e.Button == MouseButtons.Left) { if (_map.Field[x, y].Entity.OfType <AbstractUnit>().FirstOrDefault() != null) { AbstractUnit val = _map.Field[x, y].Entity.OfType <AbstractUnit>().FirstOrDefault(); LabelUnit.Text = "Unit gender: " + val.Gender + "\n" + "Unit satiety: " + val.Satiety.ToString() + "\n" + "Unit Stress: " + val.Stress.ToString() + "\n" + "Unit coordinates: " + val.X.ToString() + " " + val.Y.ToString(); } else { LabelUnit.Text = "Unit Info will be here"; } } }
public override AbstractUnit Train(AbstractUnit unit) { DecoratorUnit upgradedUnit; if (unit.GetType() == typeof(Farmer)) { upgradedUnit = new BowmanUpgrade1(unit as Farmer); } else if (unit.GetType() == typeof(BowmanUpgrade1)) { upgradedUnit = new BowmanUpgrade2(unit as BowmanUpgrade1); } else { // throw new InvalidOperationException(String.Format("Building of type {0} doesn't exist.", building.GetType().Name)); throw new InvalidOperationException(String.Format("Reached maximum upgrade level for unit [{0}] {1}.", unit.Id, unit.GetType().Name)); } upgradedUnit.Id = unit.Id; upgradedUnit.Unit = unit; return(upgradedUnit); }
public override bool Interract(bool isRemoted, AbstractUnit target, Vector3 positionTarget) { if (target == null) { return(false); } deltaTime += UnitLibData.deltaTime; bool result = false; if (body.isMoving) { result = Move(isRemoted, target, positionTarget); } if (_canShoot && deltaTime >= tickAttack) { // TODO CHANGE THIS for (int i = 0; i < body.GetNumberAlive(); i++) // Chaque entité de l'unité { float distance = Vector3.Distance(positionTarget, body.GetPosition()); float ceilAccuracy = accuracy * Mathf.Exp(Mathf.Pow(-ZoneAccuracyDispersement * (distance - OptimalDistance), 2)); // calcul de la précision if (ceilAccuracy >= Random.Range(0f, 1.0f)) { GameSingleton.Instance.soundManager.Play("ArcherAttack"); body.Attack(target, GetAttackUnit(target)); } //get efficiency type } deltaTime -= tickAttack; } return(result); }
public Spearman(AbstractUnit body) : base(body) { MultiplierScore = 2f; basisSpeed *= 2; }
public WhiteMage(AbstractUnit body) : base(body) { MultiplierScore = 2f; basisDefense *= 2; }
private void destroyItem(AbstractUnit unit) { Destroy(unit.gameObject); }
public virtual void TakeHit(AbstractUnit attacker, int power) { State = State.UNDER_ATTACK; Life -= power; }
public override void UseAbility(AbstractUnit unit) { base.UseAbility(unit); unit.RecieveDamage(getDmg(0)); }
public override void UseAbility(AbstractUnit unit) { base.UseAbility(unit); unit.RecieveDamage(getDmg(Mod.Versus(unit, tag, DMG_vs_unholy, "% DMG"))); }