private UnitStatus StatusTypeSwitch(string unitStatusName) { var unitStatus = new UnitStatus(); switch (unitStatusName) { case "Self Test": unitStatus.Name = "Self Test"; //call method to get selftest status unitStatus.State = true; unitStatus.StateToggled = true; break; case "Beeper": unitStatus.Name = "Beeper"; //call method to get selftest status break; case "Back Light": unitStatus.Name = "Back Light"; //call method to get selftest status break; case "Time And Date Logging": unitStatus.Name = "Time And Date Logging"; //call method to get selftest status break; default: //do nothing break; } return(unitStatus); }
private async Task <UnitStatus> GetFilledUnitStatus(UnitStatus unitStatus) { UnitStatus us = null; if (!string.IsNullOrEmpty(unitStatus.Name) && !string.IsNullOrEmpty(unitStatus.Code)) { us = await _ctx.Statuses.FirstOrDefaultAsync(dsc => !dsc.IsDeleted && (dsc.Name == unitStatus.Name || dsc.NameLanguage1 == unitStatus.Name || dsc.NameLanguage2 == unitStatus.Name) && dsc.Code == unitStatus.Code); } else if (!string.IsNullOrEmpty(unitStatus.Name)) { us = await _ctx.Statuses.FirstOrDefaultAsync(dsc => !dsc.IsDeleted && (dsc.Name == unitStatus.Name || dsc.NameLanguage1 == unitStatus.Name || dsc.NameLanguage2 == unitStatus.Name)); } else if (!string.IsNullOrEmpty(unitStatus.Code)) { us = await _ctx.Statuses.FirstOrDefaultAsync(dsc => !dsc.IsDeleted && dsc.Code == unitStatus.Code); } if (us == null) { throw new Exception($"Unit status by `{unitStatus.Name}` name and {unitStatus.Code} code not found"); } return(us); }
private void OnTriggerExit2D(Collider2D collision) { if (magicUnitStatus.unitCheck == true) { UnitStatus unitStatus = collision.gameObject.GetComponent <UnitStatus>(); if (collision.gameObject.tag == "Unit" && unitStatus.unitCheck == true) { healcount--; for (int i = 0; i < 20; i++) { if (healunit[i] == collision.gameObject) { healunit[i] = null; break; } } } } else { UnitStatus unitStatus = collision.gameObject.GetComponent <UnitStatus>(); if (collision.gameObject.tag == "Unit" && unitStatus.unitCheck == false) { healcount--; for (int i = 0; i < 20; i++) { if (healunit[i] == collision.gameObject) { healunit[i] = null; break; } } } } }
/// <summary> /// Start function, initializes state as well as starts state machine /// </summary> private void Start() { animator = GetComponent <Animator>(); moveContainer = MoveContainer.Load(path); unitHealth = GetComponent <UnitStatus>(); cameraTransform = GameObject.FindGameObjectWithTag("MainCamera").transform; }
void OnTriggerEnter(Collider col) { tUS = col.gameObject.GetComponent <UnitStatus>(); if ((int)tUS.whosUnit == (int)tTT.thisTileOwner && tUS.nowTile == tTT.tileNum) { switch (tUS.unitType) { case UnitStatus.UnitType.BasicMelee: case UnitStatus.UnitType.BasicRange: case UnitStatus.UnitType.BasicMagic: tUS.defPoint = (int)Mathf.Ceil(tUS.defPoint * 3.0f); tUS.defBPProp += 5; break; case UnitStatus.UnitType.EliteMelee: case UnitStatus.UnitType.EliteRange: case UnitStatus.UnitType.EliteMagic: tUS.defPoint = (int)Mathf.Ceil(tUS.defPoint * 2.5f); tUS.defBPProp += 4; break; case UnitStatus.UnitType.Champion: case UnitStatus.UnitType.Master: tUS.defPoint = (int)Mathf.Ceil(tUS.defPoint * 2.0f); tUS.defBPProp += 3; break; } } }
public void initTurn() { if (this.status != UnitStatus.DEATH) { this.status = UnitStatus.UNKNOWN; } }
//Function returns damage done in combat public int DamageDone(UnitStatus _attacker, UnitStatus _defender, bool _magicalAttack) { int damageDone = 0; if (_magicalAttack) { if (_attacker.mAttack > _defender.mArmor) { damageDone = _defender.mArmor - _attacker.mAttack; _defender.hitPoints -= damageDone; } else { damageDone = 0; } } else { if (_attacker.mAttack > _defender.mArmor) { damageDone = _defender.armor - _attacker.attack; _defender.hitPoints -= damageDone; } else { damageDone = 0; } } return(damageDone); }
public void AllyTurn(UnitStatus currentUnit) { bool isEnemyTurn = BattleManager.phase != "Turn" || currentUnit.team == "Enemy"; if (isEnemyTurn) { return; } if (Input.GetKeyDown(KeyCode.Mouse0)) { ray = Camera.main.ScreenPointToRay(new Vector3(Input.mousePosition.x, Input.mousePosition.y, 1)); bool condition = CheckTarget(currentUnit); if (!condition) { return; } Action(currentUnit); BattleManager.phase = "End"; return; } if (Input.GetKeyDown(KeyCode.D)) { BattleManager.phase = "End"; } }
public static TUnit SetStatus <TUnit>(this TUnit unit, UnitStatus status, string format, params object[] args) where TUnit : Unit { unit.Status = status; unit.StatusMessage = string.Format(format, args); return(unit); }
UnitStatus CreateUnit(string member, string team, int place) { string path = $"Сharacters/{member}"; if (member == "Empty") { return(null); } UnitStatus unit = new UnitStatus(); GameObject unitGameObject = Instantiate(Resources.Load(path, typeof(GameObject)) as GameObject); Personage unitClass = unitGameObject.GetComponent <Personage>(); /* Unit stats export */ unit.gameObject = unitGameObject; unit.gameObject.tag = team; unit.status = "Live"; unit.turn = true; unit.team = team; unit.place = place; unit.level = unitClass.level; unit.hp = unitClass.hp; unit.currentHp = unitClass.hp; unit.attack = unitClass.attack; unit.attackType = unitClass.attackType; unit.defence = unitClass.defence; unit.initiative = unitClass.initiative; unit.type = unitClass.type; unitUI.HpIndicator(unit); return(unit); }
public UnitStatus[] CreateArmy(string team) { UnitStatus[] army = new UnitStatus[6]; int count = 0; Transform parent = GameObject.Find($"{team}Team").GetComponent <Transform>(); Vector3[] unitPosition = InitPositionArray(team); Quaternion unitRotation = InitRotationArray(team); foreach (string member in group.member) { UnitStatus unit = CreateUnit(member, team, count); if (unit != null) { unit.gameObject.name = $"{team}{count + 1}"; unit.gameObject.transform.parent = parent; unit.gameObject.transform.position = unitPosition[count]; unit.gameObject.transform.rotation = unitRotation; } army[count] = unit; count++; } return(army); }
public void InflictStatus(UnitStatus newStatus) { bool wasBlockedByResistance = resistancesManager.CheckAgainstStatus(owner, newStatus); if (wasBlockedByResistance) { AudioClip sound = newStatus.deflectSound; if (sound != null) { owner.PlaySound(sound); } } else { RemoveStatus(); InflictedStatus = newStatus; newStatus.OnAdd(owner); AudioClip sound = newStatus.inflictSound; if (sound != null) { owner.PlaySound(sound); } } }
public void update(int x, int y, int hp) { this.x = x; this.y = y; this.hp = hp; this.status = UnitStatus.LIFE; }
// Use this for initialization void Start () { unitStatus = gameObject.GetComponent<UnitStatus>(); isPlayer = false; magicunit = GameObject.Find("MagicUnit"); magicunitStatus = magicunit.GetComponent<UnitStatus>(); //プレイヤーのユニットか敵のユニットか区別できるようにする //healMode = magicunit.GetComponent<MagicHealMode>(); }
private IEnumerator moveCoroutine(List <GameObject> path) { returnPos = transform.position; returnRot = transform.rotation; status = UnitStatus.Moving; playRunAnim(); for (int i = 0; i < path.Count - 1; i++) { Vector3 startPos = path[i].transform.position; Vector3 endPos = path[i + 1].transform.position; GameObject nodeObj = Grid.instance.getNodeObjFromPosition(startPos); Grid.instance.setNodeStatus(nodeObj, NodeStatus.Normal); Vector3 newDirection = (endPos - startPos).normalized; newDirection.y = 0; transform.forward = newDirection; float dist = Vector3.Distance(startPos, endPos); float distTraveled = 0; endPos.y = startPos.y = rigBody.position.y; while (!rigBody.position.Equals(endPos)) { distTraveled += GameManager.unitMoveSpeed * Time.deltaTime; rigBody.position = Vector3.Lerp(startPos, endPos, distTraveled / dist); yield return(null); } nodeObj = Grid.instance.getNodeObjFromPosition(endPos); Grid.instance.setNodeStatus(nodeObj, NodeStatus.Occupied); } playIdleAnim(); status = UnitStatus.Moved; OnMoveComplete(); }
/// <summary> /// /// </summary> protected virtual void Start() { m_characterMovement = GetComponent <CharacterMovement>(); m_status = new UnitStatus(); unitIndex = UnitManager.AddUnitBaseController(this); isAttacking = isSuccessPathFinding = false; }
public void checkDEATH() { if (this.status == UnitStatus.UNKNOWN) { this.status = UnitStatus.DEATH; } }
public void ReactToBeingHurt () { if (status == UnitStatus.Weakened) { status = UnitStatus.Dead; } else if (status == UnitStatus.Good) { status = UnitStatus.Weakened; } }
private void Awake() { mover = new Mover(this); maxUnitStatus = unitStatus; CompornentUtility.FindCompornentOnScene <UnitManager>().AddUnit(this); CompornentUtility.FindCompornentOnScene <SetUpManager>().AddSetUpAction(SetUp); }
private ActionResult InternalSaveStatus(UnitStatus status, FormCollection fields) { TryUpdateModel(status, new string[] { "StatusName", "IsActive", "WacLevel", "GetsAccount" }); //Guid unitId = new Guid(fields["Unit"]); //SarUnit unit = (from u in this.db.Units where u.Id == unitId select u).First(); //um.Unit = unit; //Guid statusId = new Guid(fields["Status"]); //UnitStatus status = (from s in this.db.SarUnitStatusTypes where s.Id == statusId select s).First(); //um.Status = status; //Guid personId = new Guid(fields["Person"]); //Member person = (from m in this.db.Members where m.Id == personId select m).First(); //um.Status = status; if (!ModelState.IsValid) { return(InternalEditStatus(status)); } this.db.SaveChanges(); return(RedirectToAction("ClosePopup")); }
/// <summary> /// 当前行动单位执行攻击 /// </summary> public void LanchAttack() { // 存储攻击者和受攻击者的属性组件 UnitStatus attackOwner = currentActUnit.GetComponent <UnitStatus>(); UnitStatus attackReceiver = currentActUnitTarget.GetComponent <UnitStatus>(); // 攻击 attackOwner.Attack(); // 被攻击方受伤 attackReceiver.Hurt(attackOwner); if (currentActUnit.tag == Const.Player) { // 保存该次选择的目标 //lastActUnitTarget = currentActUnitTarget; // 保存该次技能对象 //lastActUnitSkill = attackOwner.GetSkill(); object[] temArr = { currentActUnitTarget, attackOwner.GetSkill() }; // 不存在则添加,存在则更新 if (!battleTempDict.ContainsKey(currentActUnit)) { battleTempDict.Add(currentActUnit, new List <object>(temArr)); } else { battleTempDict[currentActUnit] = new List <object>(temArr); } } // 等待时间 StartCoroutine("WaitForTargetAct"); }
private void DamageRadius() { Vector2 target = GetComponent <PointFollower>().target; List <GameObject> units = ObjectContainer.GetAllUnits(); foreach (GameObject elt in units) { // elt == user for don't hurt self, CompareTag("Enemy") for any ally if (userTag == "Enemy" && elt.CompareTag("Enemy")) { continue; } RaycastHit2D hit = Physics2D.Raycast(target, (Vector2)elt.transform.position - target, Globals.GRENADE_YELLOW_RANGE); if (hit.collider != null && hit.collider.gameObject == elt) { UnitStatus status = elt.GetComponent <UnitStatus>(); int damage = ActionManager.DistanceToLevel(Vector2.Distance(elt.transform.position, target)); if (userTag == "Enemy" && elt.CompareTag("Player")) { damage = 1; } if (status) { status.DamageHealth(damage); } } } }
protected void updatePosition() { if (!movable) { return; } if(moveX == 0 && moveZ == 0) { status = UnitStatus.stand; return; } setDirection(); float x = transform.localPosition.x + moveX; float z = transform.localPosition.z + moveZ; float y = MapInfoManager.getInstance().getMapY(x, z); if(y != MapInfoManager.NotExist) { status = UnitStatus.move; if (lerpY == 0) lerpY = y; lerpY = Mathf.Lerp(lerpY, y, 0.1f); transform.localPosition = new Vector3(x, lerpY, z); //transform.localPosition = Vector3.MoveTowards(transform.localPosition, new Vector3(x,y,x), 1); } else { status = UnitStatus.stand; } }
public void HpIndicator(UnitStatus unitStatus) { //GameObject canvasGo = new GameObject("Canvas"); //canvasGo.transform.parent = unit.gameObject.transform; //Canvas canvas = canvasGo.AddComponent<Canvas>(); //canvas.renderMode = RenderMode.ScreenSpaceOverlay; //GameObject hp = new GameObject("Hp"); //hp.transform.parent = canvas.gameObject.transform; //hp.transform.position = unit.gameObject.transform.position; //Text hpText = hp.AddComponent<Text>(); //hpText.font = Resources.Load<Font>("arial"); //hpText.text = "Test"; var unit = unitStatus.gameObject.GetComponent <Personage>(); unit.hpBar.text = unitStatus.currentHp.ToString(); if (unitStatus.team == "Ally") { unit.hpBar.transform.rotation = Quaternion.Euler(45, -90, 0); } if (unitStatus.team == "Enemy") { unit.hpBar.transform.rotation = Quaternion.Euler(45, 90, 0); } }
public static TUnit SetStatus <TUnit>(this TUnit unit, UnitStatus status, string statusMessage = null) where TUnit : Unit { unit.Status = status; unit.StatusMessage = statusMessage; return(unit); }
void OnClick(Vector2 clickPos) { UnitStatus selectedUnitStatus = UnitStatus.Null; if (selectedUnit != null) { selectedUnitStatus = selectedUnit.Status; } if (selectedUnitStatus != UnitStatus.Moving && selectedUnitStatus != UnitStatus.Attacking && selectedUnitStatus != UnitStatus.Moved) { Node hitNode = getHitObject <Node>(clickPos, 1 << nodeLayer); if (hitNode != null) { if (hitNode.Status == NodeStatus.Occupied) { Unit hitUnit = Grid.instance.getUnitOnNode(hitNode); if (hitUnit != null && hitUnit.Status == UnitStatus.Ready && hitUnit.Team == currentTurnTeam) { setSelectedUnit(hitUnit); } } else if (hitNode.Status == NodeStatus.Attackable) { Vector3 faceDir = (hitNode.transform.position - selectedUnit.transform.position).normalized; faceDir.y = 0; selectedUnit.transform.forward = faceDir; selectedUnit.attack(Grid.instance.getUnitOnNode(hitNode)); Grid.instance.clear(); BattleMenu.instance.hideIdle(); } else if (hitNode.Status == NodeStatus.Movable) { List <GameObject> path = Grid.instance.getShortestPath(selectedUnitNodeObj, hitNode.gameObject); StartCoroutine(selectedUnit.move(path)); Grid.instance.clear(); BattleMenu.instance.hideIdle(); } } } else if (selectedUnitStatus == UnitStatus.Moved) { Node hitNode = getHitObject <Node>(clickPos, 1 << nodeLayer); if (hitNode != null) { if (hitNode.Status == NodeStatus.Attackable) { BattleMenu.instance.hide(); Vector3 faceDir = (hitNode.transform.position - selectedUnit.transform.position).normalized; faceDir.y = 0; selectedUnit.transform.forward = faceDir; selectedUnit.attack(Grid.instance.getUnitOnNode(hitNode)); } } } }
public void OnSkillButtonClick() { thisUnit = GameObject.Find("플레이어번호" + "유닛번호리스트").GetComponent <UnitStatus>(); skillImage.sprite = skillSprites[(int)thisUnit.unitFaction].Sprites[(int)thisUnit.unitType]; // 스킬패널 켜주고 그안에 이미지 버튼은 다차원배열로 팩션번호, 유닛번호로하면될듯 /* * switch (thisUnit.unitFaction) * { * * * * case UnitStatus.Faction.Academy: * switch (thisUnit.unitType) * { * // 이부분을 델리게이트 연산해서 스킬쓰게할것 * case UnitStatus.UnitType.Master: * break; * case UnitStatus.UnitType.BasicMelee: * break; * case UnitStatus.UnitType.BasicRange: * break; * case UnitStatus.UnitType.BasicMagic: * break; * case UnitStatus.UnitType.EliteMelee: * break; * case UnitStatus.UnitType.EliteRange: * break; * case UnitStatus.UnitType.EliteMagic: * break; * case UnitStatus.UnitType.Champion: * break; * } * break; * case UnitStatus.Faction.Stronghold: * switch (thisUnit.unitType) * { * case UnitStatus.UnitType.Master: * break; * case UnitStatus.UnitType.BasicMelee: * break; * case UnitStatus.UnitType.BasicRange: * break; * case UnitStatus.UnitType.BasicMagic: * break; * case UnitStatus.UnitType.EliteMelee: * break; * case UnitStatus.UnitType.EliteRange: * break; * case UnitStatus.UnitType.EliteMagic: * break; * case UnitStatus.UnitType.Champion: * break; * } * break; * } */ }
public void RemoveStatus(UnitStatus pStatus) { if (mStatuses.Contains(pStatus)) { mStatuses.Remove(pStatus); UnitUpdated?.Invoke(this, null); } }
public DeployCompletedEvent(string unitName, DeployedVersion version, UnitStatus status) { eventName = "deployCompleted"; this.unitName = unitName; this.version = version.VersionNumber; this.branch = version.VersionBranch; this.status = status.ToString(); }
void Update() { if (unitStatus != unitSO.unitStatus) { unitStatus = unitSO.unitStatus; Change(transform); } }
private void move() { //rb = objects[i].GetComponent<Rigidbody2D>(); UnitStatus status = GetComponent <UnitStatus>(); //rb.velocity = new Vector2(0, status.unitspeed); transform.Translate(0f, status.unitspeed, 0f); }
public void RemoveStatus() { if (InflictedStatus != null) { InflictedStatus.OnRemove(owner); InflictedStatus = null; } }
public Unit(UnitType unitType) { Status = UnitStatus.Inactive; Type = unitType; Scale = 1.5f; scaleMatrix = Matrix.CreateScale(this.Scale); rotationMatrixX = Matrix.Identity; rotationMatrixY = Matrix.Identity; rotationMatrixZ = Matrix.Identity; LocalRotationMatrix = Matrix.Identity; UpdateScaleRotations(); normVel = new Vector3(); //F*****g change this!! Position = Vector3.Zero; Health = 50; ID = currentID; currentID++; CurrentTileID = 0; switch (Type) { case UnitType.SpeedBoat: Damage = 50; XPToGive = 2; MoneyToGive = 5; speed = 2.0f; break; case UnitType.SpeederBoat: Damage = 100; XPToGive = 3; MoneyToGive = 10; speed = 1.0f; break; default: Damage = 10; XPToGive = 1; break; } }
protected int CompareSuppliables(UnitStatus x, UnitStatus y) { return x.WaterPercentage.CompareTo(y.WaterPercentage); }
public void SuppliableEnteredRange(UnitStatus suppliable) { if(!SuppliablesInRange.Contains(suppliable)) { SuppliablesInRange.Add(suppliable); } }
public void CloneUnit(Unit oldClone) { isSelectable = oldClone.isSelectable; isSelected = oldClone.isSelected; id = oldClone.id; enemyName = oldClone.enemyName; leader = oldClone.leader; uName = oldClone.uName; teamColor = oldClone.teamColor; label = oldClone.label; status = oldClone.status; movementType = oldClone.movementType; kills = oldClone.kills; lastDamager = oldClone.lastDamager; health = oldClone.health; weapon = oldClone.weapon; _initialWeapon = oldClone._initialWeapon; aBase = oldClone.aBase; raycastIgnoreLayers = Commander.player.raycastIgnoreLayers; weapon.Pickup(this); leader.ReplaceUnit(id, this); if (isSelected) SetOutlineColor(selectedColor); else SetOutlineColor(outlineColor); orderData = oldClone.orderData; if (orderData != null) orderData.SetUnit(this); skipSpawn = true; SetTeamColor(); Invoke("AllowSpawn", 5.0f); }
public void UpdateTargetPlayer(ref Tile newGoalTile, int newTargetPlayer) { goalTileID = newGoalTile.ID; PlayerToAttack = newTargetPlayer; SetFocalPointAndVelocity(TileMap.Tiles[CurrentTileID].PathsInts[newGoalTile.ID][1]);//currentTile.Paths[goalTile.ID][1]); Status = UnitStatus.Deployed; UpdatePath(); UpdateTransforms(); }
public void OnCapturingObjective(Objective objective) { if (objective is Base) return; if (status != UnitStatus.InCombat) { lastStatus = status; } capturingObjective = objective; status = UnitStatus.CapturingObjective; }
public void SetStatus(UnitStatus uStatus) { if (uStatus == UnitStatus.InCombat) { if (movementType == MoveType.Strict || status == UnitStatus.InCombat) return; enterCombatPosition = transform.position; lastStatus = status; status = uStatus; return; } if (status == uStatus || status == UnitStatus.InCombat || status == UnitStatus.CapturingObjective) return; status = uStatus; }
public void LeaveCombat() { if (status != UnitStatus.InCombat) return; status = lastStatus; }
public void OnCapturedObjective() { capturingObjective = null; if (status == UnitStatus.CapturingObjective) status = lastStatus; }
private void OnDied() { Unit u = this; TileMap.Tiles[u.CurrentTileID].RemoveUnit(ref u); this.Status = UnitStatus.Inactive; UnitCollection.Remove(ref u); if (Died != null) Died(ref u); }
public UnitStatusChangedEvent(string unitName, UnitStatus status) { this.eventName = "unitStatusChanged"; this.unitName = unitName; this.status = status.ToString(); }
public void SuppliableLeftRange(UnitStatus suppliable) { SuppliablesInRange.Remove(suppliable); }
public void Activate() { Status = UnitStatus.Active; Health = HealthCapacity; switch (Type) { case UnitType.SpeedBoat: Damage = 50; XPToGive = 2; MoneyToGive = 5; speed = 1.5f; HealthCapacity = 100; break; case UnitType.SpeederBoat: Damage = 100; XPToGive = 3; MoneyToGive = 10; speed = 1; HealthCapacity = 250; break; default: Damage = 10; XPToGive = 1; break; } Health = HealthCapacity; }
public void Deploy(Tile baseTile, Tile goalTile, int playerToAttack) { previousTileID = baseTile.ID; CurrentTileID = baseTile.ID; goalTileID = goalTile.ID; PlayerToAttack = playerToAttack; // this.previousTile = baseTile; //this.currentTile = baseTile; //this.goalTile = goalTile; this.Position = baseTile.Position; int count = 0; //lock (AStar2.tileInformationLock) lock(AStar2.locks[CurrentTileID][goalTile.ID]) { while (count < 60) { if (TileMap.Tiles[CurrentTileID].PathsInts[goalTile.ID].Count > 0) { SetFocalPointAndVelocity(TileMap.Tiles[CurrentTileID].PathsInts[goalTile.ID][1]);//currentTile.Paths[goalTile.ID][1]); break; } count++; if (count >= 60) { return; } } } Status = UnitStatus.Deployed; UpdatePath(); UpdateTransforms(); }