void SetOptionsFromUnit(IUnitInfo unit) { if (unit.Model.Domain != ModelDomain.Ground || unit.Model.Kind == ModelKind.SpecialCommando) { options |= Options.IgnoreZoC; } if (unit.Model.Kind == ModelKind.SpecialCommando) { options |= Options.IgnoreTreaty; } if (domain != ModelDomain.Ground || unit.IsTerrainResistant) { options |= Options.TerrainResistant; } if (unit.Model.HasFeature(ModelProperty.Overweight)) { options |= Options.Overweight; } if (unit.Model.HasFeature(ModelProperty.Alpine)) { options |= Options.Alpine; } if (unit.Model.HasFeature(ModelProperty.Navigation)) { options |= Options.Navigation; } }
// public Color RedColor; void OnPhotonInstantiate(PhotonMessageInfo info) { if (instantiationData != null) { _viewID = (int)instantiationData[0]; _shipIndex = (int)instantiationData[1]; PhotonView view = PhotonView.Find((int)instantiationData[0]); if (view == null) { if (isMine) { PhotonNetwork.Destroy(gameObject); } return; } transform.position = view.transform.position; IUnitInfo unit = Resolver.Instance.Units.Collection[_shipIndex]; Damage = unit.GetDamage(); Speed = unit.GetProjectileSpeed(); Owner = (int)instantiationData[3]; Fire((Vector2)instantiationData[2]); } else { if (isMine) { PhotonNetwork.Destroy(gameObject); } return; } }
public static UnitState CreateUnitState(IUnitInfo info) { return(new UnitState { Base = CreateObjectState(info), Destignation = info.Destignation.ToGrpc(), Direction = info.Direction.ToGrpc(), Speed = info.Speed }); }
public void onCreateUnit( int slotIndex, IUnitInfo u ) { string unitCode = theGame.getUnit (slotIndex).getOriginCard ().code; GameObject newUnit = Instantiate (boardCardObject, buildSlots [slotIndex].transform.position, Quaternion.identity) as GameObject; newUnit.GetComponent<SpriteRenderer> ().sprite = GameObject.Find (unitCode).GetComponent<SpriteBox> ().boardSprite; boardUnits [slotIndex] = newUnit.GetComponent<BoardCardScript>(); boardUnits [slotIndex].unit = u; updateUnitEnergy (slotIndex); boardUnits [slotIndex].updateAttributes (); StartCoroutine (wipeUpwardsAnim (boardUnits[slotIndex], WIPE_TIME)); }
void OnPhotonInstantiate(PhotonMessageInfo info) { if (instantiationData != null) { int id = (int)instantiationData[0]; _laneOffset = (int)instantiationData[1]; if (id < 0 || id >= Resolver.Instance.Units.Collection.Length) { if (isMine) { PhotonNetwork.Destroy(gameObject); } return; } _unit = Resolver.Instance.Units.Collection[id]; if (ownerId != PhotonNetwork.masterClient.ID) { _direction = Vector3.down; } ParseIUnitInfo(); ColorShip(); if (isMine == PhotonNetwork.isMasterClient) { MyMothership = Resolver.Instance.RoomController.GetMasterMothership(); EnemyMothership = Resolver.Instance.RoomController.GetClientMothership(); } else { EnemyMothership = Resolver.Instance.RoomController.GetMasterMothership(); MyMothership = Resolver.Instance.RoomController.GetClientMothership(); } _transform.position = MyMothership.GetTransform().position; } else { if (isMine) { PhotonNetwork.Destroy(gameObject); } return; } }
/// <summary> /// movement points an own or foreign unit has per turn, considering damage and wonders /// </summary> /// <param name="unit">the unit</param> /// <returns>movement points</returns> public static int UnitSpeed(IUnitInfo unit) { if (unit.Model.Domain == ModelDomain.Sea) { int speed = unit.Model.Speed; if (unit.Nation.HasWonder(Building.MagellansExpedition)) { speed += 200; } if (unit.Health < 100) { speed = ((speed - 250) * unit.Health / 5000) * 50 + 250; } return(speed); } else { return(unit.Model.Speed); } }
public void SetValues(IUnitInfo info) { if (_transform == null) { Initialize(); } _spawnID = info.GetIndex(); ShipImage.sprite = info.GetBlueIcon(); ShipEnergyCost.text = info.GetEnergyCost().ToString(); ShipName.text = $"{info.GetTitle()[0]}<size=7>{info.GetTitle().Remove(0,1)}</size>"; _rTransform.anchoredPosition = _defaultPosition; _selfImage.color = _srcColor; ShipImage.gameObject.SetActive(true); ShipEnergyCost.gameObject.SetActive(true); ShipName.gameObject.SetActive(true); IsEmpty = false; }
protected override void OnBeforeForeignAttack(IUnitInfo attacker, Location target, BattleOutcome outcome) { }
protected override void OnForeignMove(IUnitInfo unit, Location destination) { }
/// <summary> /// Attack a unit. Moves along shortest possible path considering all known information. /// Only does the part of the move that is possible within this turn. /// If move has to be continued next turn the return value has the Error property Incomplete. /// Operation breaks even if it could be continued within the turn if a new foreign unit or city is spotted, /// in this case the result has the NewUnitOrCitySpotted property set. /// Hostile terrain is considered to find a compromise between damage and reaching the target fast. /// </summary> /// <param name="target">unit to attack</param> /// <returns>result of operation</returns> public PlayResult Attack__Turn(IUnitInfo unit) { return(Attack__Turn(unit.Location)); }
/// <summary> /// check if the unit that owns <paramref name="manager"/> has enough resources /// to build the unit detailed in info /// </summary> /// <param name="manager">the manager to check aganst</param> /// <param name="info">the unit to check</param> /// <returns>true if the player can build info, false otherwise</returns> public static bool checkResources(CommandManager manager, IUnitInfo info) { Units.Resources cost = info.Cost; Units.Resources harvested = manager.GetComponent<BasicController>().Owner.HarvestedResources; return harvested.HasEnoughResources(cost); }
public void buildUnit(int slotIndex, IUnitInfo unit) { if (unit == null) return; TargetedAction upgradeAction = null; //Begin by destroying the old unit if( units[slotIndex] != null ) { upgradeAction = units[slotIndex].originCard.upgrader; if( upgradeAction != null ) ui.triggerFlash( new int[]{slotIndex} ); destroyUnit( slotIndex ); //If destroyed unit has an UPGRADE, it will trigger the UI flash as it's being destroyed } //Create the actual unit enqueueAction (delegate(IGameplay g) { GameUnit u = new GameUnit (); u.energy = unit.getEnergy (); u.originCard = unit.getOriginCard (); u.name = unit.getName (); //Add attributes attached to this card foreach (string attr in unit.getAttributes()) u.addAttribute (attr, (int)unit.getAttrValue (attr)); //Register triggers attached to this card foreach( Trigger t in unit.getOriginCard().getTriggers() ) registerTrigger( t, slotIndex ); units [slotIndex] = u; ui.onCreateUnit (slotIndex, u); }); //Do the UPGRADE trigger if( upgradeAction != null ) enqueueAction ( delegate(IGameplay g) { upgradeAction(g, slotIndex); }); //Supply if (getAttributeTotal (BoardManager.supplyAttr) > 0) enqueueAction( delegate(IGameplay g) { List<int> supplySlots = new List<int>(BoardManager.MAX_UNITS); int supplyTotal = 0; for( int i = 0; i < BoardManager.MAX_UNITS; ++i ) { if( i == slotIndex || units[i] == null ) continue; int? supplyValue = units[i].getAttrValue(supplyAttr); if( supplyValue != null && supplyValue != 0 ) { supplySlots.Add(i); supplyTotal += (int)supplyValue; } } if( supplySlots.Count > 0 ) g.modifyEnergy(slotIndex, supplyTotal ); ui.triggerFlash( supplySlots.ToArray() ); }); //buildup if( getAttributeTotal(BoardManager.buildupAttr) > 0 ) enqueueAction( delegate(IGameplay g) { for( int i = 0; i < BoardManager.MAX_UNITS; ++i ) { if( i == slotIndex || units[i] == null ) continue; int? buildupValue = units[i].getAttrValue(buildupAttr); if( buildupValue != null && buildupValue != 0 ) g.modifyEnergy( i, (int)buildupValue ); } }); //CreateUnit triggers (other than supply/buildup) foreach (Trigger t in allTriggers) if (t is CreateUnitTrigger) { CreateUnitTrigger captured = t as CreateUnitTrigger; if( captured.test != null && !captured.test(this, t.attachedSlot, slotIndex) ) continue; enqueueAction ( delegate(IGameplay g) { byte flags = captured.run( g, captured.attachedSlot, slotIndex); if( (flags & Trigger.FLASH) != 0 ) ui.triggerFlash( captured.attachedSlot ); if( (flags & Trigger.REMOVE) != 0 ) allTriggers.Remove( captured ); }); } }