public void Attack(UnitScript target) { if (PhaseScript.isAggressive) { myCommands.Order(new CommandScript.Target(target, myAttack)); } }
public Term() { myCardScript = null; myUnitScript = null; myPlayerScript = null; myPosition = Vector3.zero; }
bool canAttack(UnitScript defender) { //TODO: FILL THIS IN if (defender == null) return false; if (this.CompareTag(defender.tag)) return false; return true; }
public void Awake() { objectsFlagsInRange = new List<FlagScript>(); objectsInRange = new List<GameObject>(); sphereCollider = GetComponent<SphereCollider>(); unitScript = transform.parent.GetComponent<UnitScript>(); }
void OnTriggerEnter(Collider other) { if (other.gameObject.transform.tag == "Zombie") { // check parent's skill to see if zombie received headshot parentScript = sourceUnit.GetComponent<UnitScript>(); zombieScript = other.gameObject.GetComponent<ZombieScript>(); bool isMiss = false; // roll the dice float r = Random.Range(0f, 10f); if (r < parentScript.shootSkill) { // headshot zombieScript.Die(); } else if (r - 1f < parentScript.shootSkill) { // bodyshot zombieScript.Slow(); } else { // miss isMiss = true; } // destroy bullet last, parent becomes object pool if (!isMiss) this.Recycle(); } }
public void hide(){ unitUsingTimer = null; GetComponent<SpriteRenderer>().enabled = false; foreach( var item in GetComponentsInChildren<SpriteRenderer>(true) ){ item.enabled = false; } }
public void addUnit(UnitScript unit) { if (!unitsInGroupScripts.Contains(unit)) { unitsInGroup.Add(unit.gameObject); unitsInGroupScripts.Add(unit); } }
public void addUnitToBaseList(UnitScript unit) { if (unitsInGroupScripts.Contains(unit)) { unitsInGroup.Remove(unit.gameObject); unitsInGroupScripts.Remove(unit); unitsInBaseScripts.Add(unit); } }
public void SelectUnit(UnitScript unit) { if (unit != selectedUnit) StartNone(); unit.hex.highlight(Color.yellow); selectedUnit = unit; GUIMan.refreshUnitData(); }
public void SetHUD(UnitScript unit) { nameText.text = unit.unitName; levelText.text = "Lvl" + unit.unitName; enemySlider.maxValue = unit.maxHP; enemySlider.value = unit.currentHP; mcHealth.health = unit.maxHP; mcHealth.health = unit.currentHP; }
void Start() { rebind = RebindData.GetRebindManager(); unit = GetComponent<UnitScript>(); anim = GetComponent<Animator>(); //unit.OnDeath = OnDeath; unit.OnDeath = HUDScript.instance.OnPlayerDeath; }
// Use this for initialization void Awake() { unitScript = GetComponent <UnitScript>(); if (unitScript.navMeshAgent.speed != unitScript.attributeScript.CurrentMovementSpeed) { unitScript.navMeshAgent.speed = unitScript.attributeScript.CurrentMovementSpeed; } }
void Start() { TurnManager.Instance.NewTurnEvent += OnNewTurn; UsesLeft = UsesPerBattle; myUnit = GetComponent <UnitScript>(); myEnergy = GetComponent <UnitEnergy>(); AbilitySource = gameObject.AddComponent <AudioSource>(); OnStart(); }
//The player can scan one of his cards to use it, and select an unit and a hex to move it public void PlanningPhase() { card = new CardScript(); //card is scanned UseCard(card); unitToMove = new UnitScript(); //unit to move is selected do { } while (PlanMovement(unitToMove) != null); }
public static void PopUpGUI(UnitScript forUnit) { if (forUnit.gameObject.GetInstanceID() != Focus.masterGameObject.GetInstanceID()) forUnit.gameObject.AddComponent<Focus>(); Unit = forUnit; //UnitPosition = MouseEvents.State.Position; showCommandPannel = true; }
public void AddUnit(UnitScript unit) { if (units == null) { units = new HashSet <UnitScript>(); } units.Add(unit); }
internal override void OptionExtensions_OnLEFTCLICK(bool hold) { if (!hold) { if (attackState == OPTIONS.Attack) { UnitScript otherUnit = MouseEvents.State.Position.AsUnitUnderCursor; if (otherUnit) { if (UNIT.IsEnemy(otherUnit)) { UNIT.Options.Target = otherUnit.gameObject; UNIT.Options.MoveToPoint = UNIT.Options.Target.transform.position; if (!UNIT.IsABuilding) { GetComponent <Movability>().IsMoving = true; } IsAttacking = true; } else if (UNIT.IsAllied(otherUnit)) { this.UNIT.Options.Target = otherUnit.SetInteracting(this.gameObject); if (otherUnit.Options.IsAttacking) { this.UNIT.Options.Target = otherUnit.Options.Target; IsAttacking = true; UNIT.Options.MoveAsGroup(otherUnit.gameObject); } } UNIT.Options.UnlockFocus(); } } else if (attackState == OPTIONS.Conquer) { UNIT.Options.MoveToPoint = MouseEvents.State.Position; if (!GetComponent <Gunner>()) { this.gameObject.AddComponent <Gunner>(); } if (!UNIT.IsABuilding) { GetComponent <Movability>().IsMoving = true; } IsDefending = false; IsAttacking = true; IsConquering = true; GetComponent <Gunner>().FireAtWill = true; UNIT.Options.UnlockFocus(); } } }
public override void clickedInMode(HexTile clickedTile, UnitScript selectedUnit, int currentTeam) { AbsoluteDirection direction = TileController.getDirectionToTile(selectedUnit.getOccupyingHex(), clickedTile); if (direction == AbsoluteDirection.NONE) { return; } Vector2 posDir = TileController.absoluteDirectionToRelativePos(direction); int pos = -1; for (int i = 0; i < directions.Count; i++) { if (posDir == adjustedDirections[i]) { pos = i; break; } } if (pos == -1) { throw new UnityException("Issue: Charged move click on tile error, selected tile that has been marked but is NOT in any direction"); } int j = 0; while (j < ranges[pos] || ranges[pos] == -1) { HexTile tile = gameControllerRef.getTileController().getTileFromHexCoord(selectedUnit.getCoords() + posDir * (j + 1)); if (tile) { if (tile.getOccupyingUnit()) { if (tile.getOccupyingUnitTeam() == selectedUnit.getTeam()) { break; } else { gameControllerRef.captureUnit(tile.getOccupyingUnit()); } } } else { break; } j++; } gameControllerRef.getTileController().transferUnit(selectedUnit.getOccupyingHex(), clickedTile); gameControllerRef.switchInteractionState(InteractionStates.SelectingUnitToRotate); }
void Start() { player = PlayerScript.instance; unit = transform.GetComponent<UnitScript>(); timer = new Timer(); shootTimer = new Timer(); shootTimer.SetMaximumTime(shootInterval); }
public override void clickedInMode(HexTile clickedTile, UnitScript selectedUnit, int currentTeam) { if (clickedTile.getOccupyingUnit()) { gameControllerRef.captureUnit(clickedTile.getOccupyingUnit()); } gameControllerRef.getTileController().transferUnit(selectedUnit.getOccupyingHex(), clickedTile); gameControllerRef.switchInteractionState(InteractionStates.SelectingUnitToRotate); }
public void drinkPotion() { UnitScript S = characterObjects[selectedCharacter].GetComponent <UnitScript>(); if (S.inventory == "potion") { S.hp += 30; S.inventory = "none"; } }
private void SelectTarget() { RaycastHit2D hit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero, Mathf.Infinity, unitLayer); if (hit.collider && hit.transform != unit) { targetUnit = hit.transform; targetScript = targetUnit.GetComponent <UnitScript>(); } }
void Update() { UnitScript currentUnit = MouseManager.Instance.SelectedUnit; if (currentUnit == null) { return; } thisText.text = "Enemies to escape: " + currentUnit.EnemyList.Count + "\n" + "Chances of getting attacked: " + CountTheChances(currentUnit); }
protected override void TriggerExit(Collider collider) { base.TriggerExit(collider); if (collider.tag == "Player" && collider.GetComponent <UnitScript>().ColliderIsBody(collider)) { unit_target = null; pasttarget_coordinates = Vector2.zero; } }
private void Start() { myUnit = this.transform.root.GetComponent <UnitScript>(); myShooting = this.transform.root.GetComponent <ShootingScript>(); myHowler = this.transform.root.GetComponent <Ability_Elves_Wolf_Howl>(); mySwapper = this.transform.root.GetComponent <Ability_Neutral_SwapWeapons>(); myThrower = this.transform.root.GetComponent <Ability_Elves_Assassin_DaggerThrow>(); myCry = this.transform.root.GetComponent <Ability_Hero_Knight_Battlecry>(); myPikeman = this.transform.root.GetComponent <Ability_Human_Pikeman_SpearBarricade>(); }
void MeleeAttackObstacle(UnitScript Attacker, DestructibleScript target) { Debug.Log("Melee attacking obstacle - debugging fencer bug"); Attacker.GetComponent <UnitMovement>().LookAtTheTarget(target.transform.position, Attacker.GetComponentInChildren <BodyTrigger>().RotationInAttack); Attacker.GetComponentInChildren <AnimController>().AnimateAttack(); target.GetDamaged(Attacker.CurrentAttack + 1); Attacker.hasAttacked = true; CheckIfLastAttacker(); target.GetComponentInChildren <ObjectHP>().SwitchTrigger(); }
protected BasePage(ConditionModel model) { _model = model; _unitQuery = new UnitQuery(model); _unitFunc = new UnitFunc(model); _unitList = new UnitList(model); _unitListEdit = new UnitListEdit(model); _unitEdit = new UnitEdit(model); _unitScript = new UnitScript(model); }
void OnTriggerEnter2D(Collider2D obj) { UnitScript US = obj.GetComponent <UnitScript>(); if (US) { US.LostHp(damage); //Destroy(gameObject); } }
public void EquipUnit(int index, int level, int star) { UnitScript _unit = new UnitScript(index, level, star); _unit.PlayerOwner = this; if (!ListEquippedUnit.Exists(x => x == _unit)) { ListEquippedUnit.Add(_unit); } }
void Start() { player = PlayerScript.instance; unit = transform.GetComponent <UnitScript>(); timer = new Timer(); shootTimer = new Timer(); shootTimer.SetMaximumTime(shootInterval); }
private void Start() { CurrentProjectile = Projectile; TurnManager.Instance.NewTurnEvent += OnNewTurn; currMinimalRange = baseMinimalRange; currShootingRange = baseShootingRange; theUnit = this.GetComponent <UnitScript>(); hitShotSource = gameObject.AddComponent <AudioSource>(); shootSource = gameObject.AddComponent <AudioSource>(); }
void Update() { if (myWaves > 0) { if (myWait <= 0f) { myWait = 10f; Debug.Log("Wait done"); bool ready = true; foreach (UnitScript unit in myBugs) { if (unit && unit.GetComponent <HealthScript>().isAlive) { ready = false; break; } } if (ready) { Debug.Log("All Clear"); foreach (GameObject spawn in mySpawns) { for (int i = 0; i < 2; i++) { UnitScript unit = Instantiate(myUnit).GetComponent <UnitScript>(); unit.transform.position = spawn.transform.position; AggroScript aggro = unit.GetComponent <AggroScript>(); aggro.myRange = 9999f; myBugs.Add(unit); } } if (1 == myWaves) { Debug.Log("Boss Wave"); AggroScript aggro = myBoss.GetComponent <AggroScript>(); aggro.myRange = 9999f; } myWaves--; } } else { myWait -= Time.deltaTime; } } }
public override void drawMovementIcons(UnitScript selectedUnit) { //gameControllerRef.printString("Meowsquers"); for (int i = 0; i < adjustedLocations.Count; i++) { bool foundEnemy = false; bool foundFriend = false; bool onlyFriends = false; for (int j = 0; j < adjustedLocations[i].Count; j++) { HexTile tile = gameControllerRef.getTileController().getTileFromHexCoord(selectedUnit.getOccupyingHex().getCoords() + adjustedLocations[i][j]); if (tile) { InteractionIcon.createInteractionIcon("RangedIcon", tile.getCoords(), new Color(0.0f, 1.0f, 0.0f, 1.0f), 0); if (!foundEnemy && !onlyFriends) { if (tile.getOccupyingUnit()) { if (tile.getOccupyingUnit().getTeam() != selectedUnit.getTeam()) { foundEnemy = true; foundFriend = false; j = -1; //clearMovementIcons(); continue; } else { foundFriend = true; } } if (foundFriend && j == adjustedLocations[i].Count - 1) { onlyFriends = true; j = -1; //clearMovementIcons(); continue; } } else if (foundEnemy) { tile.switchState(TileState.SELECTABLE); //createMovementIcon("RangedIcon", tile.getCoords(), new Color(0.0f, 1.0f, 0.0f, 1.0f), 0); InteractionIcon.createInteractionIcon("AttackIcon", tile.getCoords(), new Color(1.0f, 0.0f, 0.0f, 1.0f), 1); } else { //createMovementIcon("RangedIcon", tile.getCoords(), new Color(0.0f, 1.0f, 0.0f, 1.0f), 0); InteractionIcon.createInteractionIcon("CrossIcon", tile.getCoords(), new Color(1.0f, 0.0f, 0.0f, 1.0f), 1); } } } } }
public static void UpdateAbilitiesPanel(GameObject Panel, GameObject Prefab, UnitScript Unit) { RemoveChildrenOf(Panel.transform); foreach (Ability_Basic ability in Unit.GetComponents <Ability_Basic>()) { ability.MyObject = Instantiate(Prefab, Panel.transform); ability.MyObject.GetComponentInChildren <AbilityIconScript>().myAbility = ability; ability.MyObject.GetComponentInChildren <AbilityIconScript>().myImage.sprite = ability.mySprite; ability.MyObject.GetComponentInChildren <Button>().onClick.AddListener(delegate { ability.BaseUse(); }); } }
public void DestroyRealUnit(UnitScript unit) { if (unit.PlayerID == 0) { NewGameScript.PlayerOneArmy.Remove(unit.transform.position); } else { NewGameScript.PlayerTwoArmy.Remove(unit.transform.position); } }
// this one will be used for following a unit as long as the "condition" for continuing the loop is met - like "follow unit untill it ends its movement". IEnumerator SetCameraToUnit(UnitScript unit, bool condition) { manualCamera = false; while (condition) { transform.position = Vector3.Lerp(transform.position, unit.transform.position + new Vector3(0, startector.y, -3), Time.deltaTime * transitionSpeed); LocalRotation = Quaternion.identity.eulerAngles; yield return(null); } manualCamera = true; }
private void InitOver() { mainCamera.enabled = true; timeList = StaticData.GetList <TimeSDS>(); timeList[0].timeLong = timeList[0].time; for (int i = 1; i < timeList.Count; i++) { timeList[i].timeLong = timeList[i - 1].timeLong + timeList[i].time; } stepV = new Vector2(mainCamera.aspect * mainCamera.orthographicSize, mainCamera.orthographicSize); UnitScript.lineWidth = stepV.x * 2 / ConfigDictionary.Instance.lineNum; createGap = stepV.x * 2 / ConfigDictionary.Instance.lineNum; Application.targetFrameRate = 60; xPosArr = new float[ConfigDictionary.Instance.lineNum]; float lineWidth = stepV.x * 2 / ConfigDictionary.Instance.lineNum; for (int i = 0; i < ConfigDictionary.Instance.lineNum; i++) { float x = -stepV.x + lineWidth * i + lineWidth * 0.5f; xPosArr[i] = x; } humanGo = Create(ConfigDictionary.Instance.humanSpriteName, ConfigDictionary.Instance.humanRadius, null); humanGo.transform.localPosition = new Vector3(0, -stepV.y + stepV.y * 2 * ConfigDictionary.Instance.humanPosY, -1); humanAnimator = humanGo.gameObject.AddComponent <Animator>(); humanAnimator.runtimeAnimatorController = ra; timer.sprite = TextureFactory.Instance.GetTexture <Sprite>(string.Format(UnitScript.spritePath, "blank"), null, true); timerScaleX = stepV.x / (timer.sprite.rect.width * 0.5f / timer.sprite.pixelsPerUnit); timerScaleY = timerHeight * stepV.y / (timer.sprite.rect.height * 0.5f / timer.sprite.pixelsPerUnit); tm.transform.position = new Vector3(0, stepV.y - timerHeight * stepV.y * 2f, -2); time = ConfigDictionary.Instance.time; score = 0; StartGame(); }
public void AddUnitToEnemyArmy(UnitScript unit) { enemyArmy.Add(unit); // si la unidad es enemiga y soy defensor (lado izquierdo) hace flip if (GameManager.instance.playerBattleSide == 0) { unit.flipUnit(); } unit.transform.SetParent(map.enemyUnitContainer); }
void Start() { unit_GlobalRotation = transform.FindDeepChild("UnitAngleContainer"); unit_LocalYAxisRotation = transform.FindDeepChild("UnitContainer"); camera_Pivot = transform.FindDeepChild("Player_Pivot"); unitScript = GetComponent <UnitScript>(); _nodes = new List <Vector3Int>(); _newPathNodes = new List <Vector3Int>(); }
public override int GetAttack(UnitScript other) { if (myUnit.EnemyList.Count == 1) { return(AttackModifierVersusUnitType); } else { return(0); } }
public Term( PlayerScript inPlayerScript, CardScript inCardScript, UnitScript inUnitScript, Vector3 inposition) { myCardScript = inCardScript; myUnitScript = inUnitScript; myPlayerScript = inPlayerScript; myPosition = inposition; }
public AttackState(UnitScript unitScript) : base(unitScript) { if (unitScript.gameObject.CompareTag("Player")) { layerMask = LayerMask.GetMask("Enemy"); } else if (unitScript.gameObject.CompareTag("Enemy")) { layerMask = LayerMask.GetMask("Player"); } }
void UpdateSelectedUnit() { if (GameStateManager.Instance.IsCurrentPlayerAI() == false) { unitWeShowStatsOf = MouseManager.Instance.SelectedUnit; } if (GameStateManager.Instance.IsCurrentPlayerAI() == true) { SetOurOwnUnitSelection(); } }
/// <summary> /// Sets the unit as selected. /// The gridblock should call this after it is clicked. /// Passing null will deselect a unit. /// </summary> /// <param name="u">Unit.</param> public void setSelectedUnit(UnitScript u){ //If another or no unit is selected. if(currentlySelectedUnit != u){ currentlySelectedUnit = u; if(u != null){ setButtons(u.getButtonPrefabs()); timer.setUnitUsingTimer(u); timer.show(); } else{ resetButton(); timer.hide(); } } }
void Awake() { myUnit = GetComponent<UnitScript>(); if(null == myUnit) { } else { Debug.Log("Production.myOwner: " + myUnit.myOwner.owner); myUnit.myOwner.owner.myProduction.Add(this); } }
//Constructor for AI. public AttackScript(UnitScript u, GridBlock attackLocation) : this(u){ this.attackLocation = attackLocation; if(attackLocation.unitInstalled == null) Debug.LogWarning("No unit to attack!"); SerializedCompletedAction sac = new SerializedCompletedAction(); sac.locationToPerformAction = attackLocation.gridLocation; sac.actionAmountInt = unit.getAttackPower(); loadAction(sac); u.addActionToQueue(this); }
protected void UpdateProduction(UnitScript.UNITTYPE type) { int dividier = 1; bool allowed = false; if (type == UnitScript.UNITTYPE.MatterMine) { dividier = MatterMineCount; MatterCount++; if (MatterCount > MatterMineCount) MatterCount = 1; if (MatterCount == 1) allowed = true; } else if (type == UnitScript.UNITTYPE.NaniteMine) { dividier = NaniteMineCount; NaniteCount++; if (NaniteCount > NaniteMineCount) NaniteCount = 1; if (NaniteCount == 1) allowed = true; } // If Player has several Miner -> only execute the first miner for counting all if (allowed) { if (allowed) { //Timer for Resources per Time (ProductionTime) this.workTimer += Time.deltaTime; if (this.workTimer >= (float)1 / (float)this.CurrentResource / dividier) { this.workTimer = 0; this.MineWork(); } } } //calls the method only once if (this.firstStart) { this.firstStart = false; //MatterMineEnergyConsumption(); // BuildingCost(); } //Check for Upgrade // UpgradeBuilding(); }
protected override void HitUnit(UnitScript unit, Vector2 hitPos, int penetration = 0) { // Create effects GameObject newblood = ObjectPoolScript.instance.GetObjectForType("blood", false); newblood.transform.position = VectorExt.V2toV3(hitPos); newblood.transform.localRotation = Quaternion.AngleAxis(-playerMove.GetDirection().x * 90, Vector3.up); // Damage unit int damage = damageMin + Random.Range(0, damageVariation); damage /= (penetration + 1); unit.DamageUnit(damage); unit.KnockbackUnit(playerMove.GetDirection() * knockbackForce); // Log Debug.Log("damaged " + damage.ToString() + " on unit " + unit.name); }
public UnitComponent PflongeOnUnit(System.Array newextensions) { if (ComponentExtendsTheOptionalstateOrder) { UNIT = this.gameObject.GetComponent<UnitScript>(); StateExtensions = new System.Enum[newextensions.Length]; newextensions.CopyTo(StateExtensions, 0); this.ID = UNIT.Options.RegisterUnitComponent(this, StateExtensions); SignIn(); return this; } else return PflongeOnUnit(); }
void Start() { SettingFocusIsComplete = false; if (firststart == false) { if ((!IsLocked) || (IsLockedToThis)) { if (this.gameObject.GetComponent<UnitScript>()) UNIT = this.gameObject.GetComponent<UnitScript>(); masterGameObject = this.gameObject; } if (!IsLocked) { UpdateManager.OnUpdate += DoUpdate; MouseEvents.RIGHTCLICK += MouseEvents_RIGHTCLICK; MouseEvents.LEFTCLICK += MouseEvents_LEFTCLICK; SettingFocusIsComplete = true; } // Add Healthbar it not there if (UNIT) UNIT.ShowLifebar(); if (SettingFocusIsComplete) { GUIScript.SelectedGroup.ResetGroup(); } } else { //-Focus's first start: //-References needet by The Focus. It is called only once, at Gamestart. //-when References have been copied, this childopjects will be detached // and Focus will Destroy itself, keeping this references in its Static part of it's class) Focusrectangle = this.gameObject; Marker[0] = GUIScript.main.transform.FindChild("MoveToPoint").gameObject.GetComponent<MarkerScript>(); Marker[1] = GUIScript.main.transform.FindChild("WayPoint").GetComponent<MarkerScript>(); Marker[2] = GUIScript.main.transform.FindChild("AttackPoint").GetComponent<MarkerScript>(); GUIScript.main.transform.DetachChildren(); foreach (MarkerScript marker in Marker) marker.Visible = false; Component.Destroy(this.gameObject.GetComponent<Focus>()); } }
public void Move() { if (mode != Mode.Movement) return; if (selectedUnit != null && selectedHex != null) { if (selectedHex.Distance(selectedUnit.hex) <= selectedUnit.mobility) { selectedUnit.Move(selectedHex); selectedUnit = null; selectedHex = null; hexfieldMan.DeselectAll(); } else selectedHex = null; } }
public UnitAI(UnitScript unit) { this.unit = unit; moveDir = 0.5; moveIdle = 0; moveScope = 0.5; moveGlobalScope = 0.5; moveTarget = 0.5; moveTeam = 0.5; attack = 0.5; moveDirB = MoveDirBehavior.IDLE; moveScopeB = MoveScopeBehavior.MICRO; moveTargetB = MoveTargetBehavior.HEAD; moveTeamB = MoveTeamBehavior.ENEMY; attackB = AttackBehavior.MICRO; }
UnitScript[] deploy(Unit[] units, Transform root, Side side) { int index = 0; var scripts = new UnitScript[units.Length]; foreach (var unit in units) { var unitGameObject = GameObject.Instantiate(unitPrefab); unitGameObject.transform.parent = root; var script = unitGameObject.GetComponent<UnitScript>(); script.Deploy( unit, side); scripts[index] = script; ++index; } return scripts; }
public UnitComponent PflongeOnUnit() { if (ComponentExtendsTheOptionalstateOrder) { throw new UnitComponentExeption(this.gameObject.GetInstanceID(), this.IDstring, "tryed Pflontshing on a 'UnitEtension'. It needs it's 'OPTIONS'-enum's Type as parameter !\nTry: 'PflongeOnUnit(typof(OPTIONS))'. !!!"); } else { UNIT = this.gameObject.GetComponent<UnitScript>(); StateExtensions[0] = EnumProvider.ORDERSLIST.Cancel; this.ID = UNIT.Options.RegisterUnitComponent(this, StateExtensions); SignIn(); return this; } }
public UnitComponent PflongeOnUnit(System.Type optionsType) { if (ComponentExtendsTheOptionalstateOrder) { UNIT = this.gameObject.GetComponent<UnitScript>(); StateExtensions = new System.Enum[System.Enum.GetValues(optionsType).Length]; System.Enum.GetValues(optionsType).CopyTo(StateExtensions, 0); this.ID = UNIT.Options.RegisterUnitComponent(this, StateExtensions); SignIn(); return this; } else { return PflongeOnUnit(); } }
//Constructor for AI. public MoveScript(UnitScript u, GridBlock b) : this(u){ bool validMove = false; adjBlocks = new GridBlock[4]; for(int i = 0; i < adjBlocks.Length; i++){ adjBlocks[i] = u.getBlockList().First.Value.getAdj(i); if(b == adjBlocks[i]) validMove = true; } if(!validMove) Debug.LogWarning("Move not valid!"); SerializedCompletedAction sac = new SerializedCompletedAction(); sac.locationToPerformAction = b.gridLocation; loadAction(sac); u.addActionToQueue(this); }
/// <summary> /// Adds to unit acting queue. /// </summary> public void addToUnitActing(UnitScript currentlySelectedUnit){ UnitActingScript temp = Instantiate(unitActingPrefab).GetComponent<UnitActingScript>(); temp.transform.SetParent(currentProgramStartPosition); //Each unit acting image is 50f apart. temp.location.anchoredPosition = new Vector2(0, actingQueue.Count * -50f); temp.setUnit(currentlySelectedUnit); actingQueue.Enqueue(temp); if(actingQueue.Count == 1){ if(Player.Instance.workingOnline){ //Online check Player.Instance.thisPlayersNetworkHelper.Cmd_incNumberOfReadyClients(); } else{ if(!temp.setCurrentlyActing()){ currentUnitDoneActing(); } } } else if(actingQueue.Count > maxVisibleItems){ temp.setVisible(false); } }
/* Given a unit type and hex type, the cost of the given unit moving through the tile is returned. */ public static int move_cost(UnitScript.Types u_type, HexScript.HexEnum h_type) { if (u_type == Types.H_Infantry || u_type == Types.A_Infantry) { switch (h_type) { case HexScript.HexEnum.plains: return 1; case HexScript.HexEnum.desert: return 1; case HexScript.HexEnum.mountain: return 3; case HexScript.HexEnum.water: return 9999; } } else if (u_type == Types.H_Exo || u_type == Types.A_Elite) { switch (h_type) { case HexScript.HexEnum.plains: return 1; case HexScript.HexEnum.desert: return 1; case HexScript.HexEnum.mountain: return 1; case HexScript.HexEnum.water: return 9999; } } else if (u_type == Types.H_Tank || u_type == Types.A_Tank) { switch (h_type) { case HexScript.HexEnum.plains: return 1; case HexScript.HexEnum.desert: return 2; case HexScript.HexEnum.mountain: return 9999; case HexScript.HexEnum.water: return 9999; } } else if (u_type == Types.H_Artillery || u_type == Types.A_Artillery) { switch (h_type) { case HexScript.HexEnum.plains: return 1; case HexScript.HexEnum.desert: return 3; case HexScript.HexEnum.mountain: return 9999; case HexScript.HexEnum.water: return 9999; } } else if (u_type == Types.H_Base || u_type == Types.A_Base) { switch (h_type) { case HexScript.HexEnum.plains: return 1; case HexScript.HexEnum.desert: return 1; case HexScript.HexEnum.mountain: return 1; case HexScript.HexEnum.water: return 1; } } // not a valid unit type return 9999; }
void MoveControl() { unit = mover.GetComponent<UnitScript>(); foreach(Vector2 node in available){ if(node == destination) viableFlag = true; } if(viableFlag){ // rxl244: if statement prevents player from moving enemy units if(unit.team != 2){ unit.SendMessage("moveTo", destination); } //reset values destination = Vector2.zero; mover = null; available = null; } viableFlag = false; // Debug.Log ("unit moved"); }
// Update is called once per frame void Update() { if (GameManagerScript.instance.getHoveredUnit () != null) { unit = GameManagerScript.instance.getHoveredUnit (); health.text = "" + unit.getHealth (); attack.text = "" + unit.getAttack (); defense.text = "" + unit.getDefense (); range.text = "" + unit.getRange(); movement.text = "" + unit.getMovement (); if (unitName != null) { string unitText = unit.unitType ().ToString(); unitText = unitText.Substring (2); unitName.text = unitText; } if (unitSprite != null) { unitSprite.sprite = unit.gameObject.GetComponent<SpriteRenderer>().sprite; } } else if (GameManagerScript.instance.getFocusedUnit () != null) { unit = GameManagerScript.instance.getFocusedUnit (); health.text = "" + unit.getHealth (); attack.text = "" + unit.getAttack (); defense.text = "" + unit.getDefense (); range.text = "" + unit.getRange(); movement.text = "" + unit.getMovement (); if (unitName != null) { string unitText = unit.unitType ().ToString(); unitText = unitText.Substring (2); unitName.text = unitText; } if (unitSprite != null) { unitSprite.sprite = unit.gameObject.GetComponent<SpriteRenderer>().sprite; } } currency.text = "" + GameManagerScript.instance.getPlayer().getCurrency(); deckCount.text = "" + GameManagerScript.instance.getDeckCount (); discardCount.text = "" + GameManagerScript.instance.getDiscardCount (); }