public override void Ready() { Transform Prefab = null; switch (Type) { case EnmType.Enm01: Prefab = FloorManager.Instance.Enm01Prefab; break; } Transform tComponen = UnityEngine.Object.Instantiate(Prefab, new Vector3(X, Y, ZPos), Quaternion.identity) as Transform; tComponen.gameObject.name = Name; UnitControl unitCtl = tComponen.gameObject.GetComponent(typeof(UnitControl)) as UnitControl; // memo Stateにより表示状態を変更 switch (State) { case EnmState.Hide: unitCtl.ReqChangeHide(); break; case EnmState.Active: unitCtl.ReqChangeActive(); break; } SetPanelEvent(Vector2I.InvalidPos, Vector2); base.Ready(); }
//for LOS checking along a path, //return true if the unit will be seen by hostile faction if the unit moves along the path, false if otherwise bool CheckEncounterOnPath(Tile srcTile, Tile targetTile) { List <Tile> path = AStar.SearchWalkableTile(srcTile, targetTile); List <UnitTB> allPlayerUnit = UnitControl.GetAllUnitsOfFaction(0); bool visibleToPlayer = false; for (int i = 0; i < path.Count; i++) { Tile tile = path[0]; for (int j = 0; j < allPlayerUnit.Count; j++) { if (GridManager.IsInLOS(tile, allPlayerUnit[j].occupiedTile)) { int dist = GridManager.Distance(tile, allPlayerUnit[j].occupiedTile); if (dist <= allPlayerUnit[j].GetSight()) { visibleToPlayer = true; break; } } } } return(visibleToPlayer); }
public void SetUp(SkeletonData setUpData) { root = setUpData.rootTransform; rightHand = setUpData.rightHand; leftHand = setUpData.leftHand; leftArmPart = setUpData.leftArmPart; leftArmPart.Skeleton = this; rightArmPart = setUpData.rightArmPart; rightArmPart.Skeleton = this; leftLegPart = setUpData.leftLegPart; leftLegPart.Skeleton = this; rightLegPart = setUpData.rightLegPart; rightLegPart.Skeleton = this; headPart = setUpData.headPart; headPart.Skeleton = this; torsoPart = setUpData.torsoPart; torsoPart.Skeleton = this; foreach (JointData joint in setUpData.joints) { SetUpJoint(joint, setUpData.layerName); } unitControl = GetComponent <UnitControl>(); animator = GetComponent <Animator>(); gameManager = GameManager.Instance; }
public override void StateUpdate() { base.StateUpdate(); if (!brain.CurrentTarget || brain.CurrentTarget.IsDestroyed) { brain.State = "Idle"; return; } if (!CanSeeEnemy(brain.CurrentTarget)) { brain.State = "Idle"; return; } if (brain.InMeleeRange || brain.InMissileRange) { animator.SetTrigger("ChargeAttack"); brain.State = "Attacking"; } float distance = brain.DistanceToTarget; UnitControl betterTarget = brain.ScanForTargets(); if (betterTarget && betterTarget != brain.CurrentTarget) { brain.AttackTarget(betterTarget); } }
void Update() { if (coolDownTimer > 0) { coolDownTimer -= Time.deltaTime; return; } if (!isReady || orders.Count < 1) { return; } UnitOrder order = orders[0]; GameObject newUnit = gameManager.UnitFactory.CreateUnit(order.unitType, spawnPoint.position, spawnPoint.rotation); UnitControl newUnitControl = newUnit.GetComponent <UnitControl>(); order.owner.AddUnit(newUnitControl); newUnitControl.TeamName = order.owner.tag; newUnitControl.UnitType = order.unitType; newUnitControl.Cluster = order.owner; newUnit.name = order.owner.tag + "-" + order.unitType; newUnit.layer = LayerMask.NameToLayer(order.owner.tag); newUnit.GetComponent <UnitBrain>().MoveTo(order.owner.transform.position); order.amount--; coolDownTimer = coolDown; if (order.amount <= 0) { orders.Remove(order); } }
// Update is called once per frame void Update() { if (UnitControl.FindObjectOfType <UnitControl>().unitsSpawned) { spawnAnim.SetBool("spawnNow", false); } }
void explode(GameObject target) { GameObject[] units = GameObject.FindGameObjectsWithTag("Unit"); foreach (GameObject unit in units) { UnitControl unitControl = unit.GetComponent <UnitControl>(); if (unitControl != null) { if (unit == target) { unitControl.takeDamage(damage); } else { float dist = Vector3.Distance(transform.position, unit.transform.position); if (dist < range) { unitControl.takeDamage((int)(damage * (1f - dist / range))); } } } } Instantiate(explosionEffect, transform.position, new Quaternion()); Destroy(gameObject); }
public void UnitHit(UnitControl unitControl, CombotPart part) { if (unitControl.IsPlayer) { uiControl.AddDamageUI(part); } }
void OnCollisionEnter(Collision collision) { if (collision.gameObject.tag.Equals("Projectile")) { return; } inAir = false; if (explosive) { Explode(); return; } if (collision.gameObject.tag.Equals(enemyTag)) { Destroy(rbody); Destroy(myCollision); transform.parent = collision.transform; UnitControl enemy = collision.gameObject.GetComponent <UnitControl>(); if (enemy) { enemy.TakeDamage(damage); } } }
protected override void CollidedWithEnemy(UnitControl enemy) { if (isActive && enemy.transform.tag.Equals(brain.EnemyTag)) { animator.SetTrigger("ChargeAttack"); brain.AttackTarget(enemy.gameObject.GetComponent <UnitControl>()); } }
public DamageInfo(float _amount, DamageType _type, UnitControl _attacker) { damageAmount = _amount; type = _type; position = _attacker.transform.position; attacker = _attacker; isDirectional = true; }
void Start() { unitAttack = GetComponent <UnitAttack>(); unitControl = GetComponent <UnitControl>(); animator = GetComponent <Animator>(); animator.SetFloat("random", Random.value); homePosition = transform.position; }
public DamageInfo(float _amount, DamageType _type) { damageAmount = _amount; type = _type; position = Vector3.zero; attacker = null; isDirectional = false; }
public DamageInfo(float _amount, DamageType _type, Vector3 _position) { damageAmount = _amount; type = _type; position = _position; attacker = null; isDirectional = true; }
public UnitControlMovement(int x, int y, GridControl tiles, UnitControl units) { this.sizex = x; this.sizey = y; TilesSpec = tiles; UnitsSpec = units; clear(); }
public void RemoveUnit(UnitControl unit) { Units.Remove(unit); unitLost.Invoke(unit); if (Units.Count == 0) { gameManager.InputControl.RemoveCluster(this); } }
override public void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { if (!unitControl) { unitControl = animator.gameObject.GetComponent <UnitControl>(); } unitControl.DefenseComplete(); }
private void OnCollisionEnter(Collision other) { UnitControl control = other.gameObject.GetComponent <UnitControl>(); if (control && control.transform.tag.Equals(brain.EnemyTag)) { CollidedWithEnemy(control); } }
override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { if (!unitControl) { unitControl = animator.gameObject.GetComponent <UnitControl>(); } unitControl.SetAttackState(true); }
public virtual void StateInit() { gameManager = GameManager.Instance; ai = GetComponent <AIController>(); unitControl = GetComponent <UnitControl>(); unitAttack = GetComponent <UnitAttack>(); unitMover = GetComponent <UnitMover>(); mapControl = gameManager.ActiveMap; }
public virtual void Move(Vector3 pos) { if (IsSelected) { unitControl = gameObject.GetComponent <UnitControl>(); unitControl.GoToPositions(pos); Deselect(); } }
public virtual void Init(UnitControl _unitControl) { unitControl = _unitControl; if (animOverride != null) { unitControl.gameObject.GetComponent <Animator>().runtimeAnimatorController = animOverride; } }
public virtual void StateInit() { unitControl = GetComponent <UnitControl>(); animator = GetComponent <Animator>(); brain = GetComponent <UnitBrain>(); navAgent = GetComponent <NavMeshAgent>(); rbody = GetComponent <Rigidbody>(); terrainMask = LayerMask.GetMask("Terrain"); }
virtual public void FinishAttack() { UnitControl enemy = unitControl.GetCurrentEnemy(); if (enemy) { enemy.TakeDamage(damage); } }
/////////////////////////////////////////////////////////////////////////// // Functions to persist attributes private void SaveDimension(CSSAttribute ai, UnitControl unitDim) { string value = SaveDimensionUI(unitDim); Debug.Assert(value != null, "saveDimensionUI returned null!"); ai.SaveAttribute(GetSelectedStyles(), value); }
void Start() { animator = GetComponent <Animator>(); gameManager = GameManager.instance; unitControl = GetComponent <UnitControl>(); Build(); InitializeParts(); StartCoroutine(BindAnimator()); }
public static void HealAllFriendlyUnit(int factionID) { List <UnitTB> list = UnitControl.GetAllUnitsOfFaction(factionID); foreach (UnitTB unit in list) { int val = Random.Range(2, 6); unit.ApplyHeal(val); } }
IEnumerator BindAnimator() { yield return(new WaitForEndOfFrame()); animator.Rebind(); unitControl = GetComponent <UnitControl>(); SetupAttachPoints(unitControl); unitControl.Init(); Destroy(this); }
private void AddUnitControl(Unit unit) { UnitControl unitControl = new UnitControl(unit); unitControl.Click += this.UnitControl_Click; this.pnlField.Controls.Add(unitControl); unitControl.BringToFront(); this.unitControls.Add(unit, unitControl); }
private void UnitControl_Click(object sender, EventArgs e) { UnitControl unitControl = (UnitControl)sender; DataGridViewRow row = this.GetRow(unitControl.Unit); row.Selected = true; this.game.OnSelectUnit(unitControl.Unit); }
void Awake(){ instance=this; List<Tile> allTiles=GridManager.GetAllTiles(); foreach(Tile tile in allTiles){ if(tile.unit!=null){ UnitTB unit=tile.unit; allUnits.Add(unit); } } currentUnitTurnID=-1; #if ibox if(playerUnits==null || playerUnits.Count==0){ playerUnits=new List<PlayerUnits>(); playerUnits.Add(new PlayerUnits(GameControlTB.instance.playerFactionID[0])); } #endif }
void Awake() { gc=(GameControlTB)target; uc=gc.gameObject.GetComponent<UnitControl>(); InitLabel(); if(gc.playerFactionID==null || gc.playerFactionID.Count==0){ gc.playerFactionID=new List<int>(); gc.playerFactionID.Add(0); } }
void Awake() { LoadUnit(); uc=(UnitControl)target; gc=uc.gameObject.GetComponent<GameControlTB>(); if(gc!=null) InitPlayerUnitsList(); }