public static LinkLine GetLinkLineBetween(TroopContainer c1, TroopContainer c2) { foreach (LinkLine line in instance.linkLines) { if (line.LinksContainer(c1) && line.LinksContainer(c2)) { return(line); } } return(null); }
/// <summary> /// true if this link is connected to the target container /// </summary> /// <param name="targetCont"></param> /// <returns></returns> public bool LinksContainer(TroopContainer targetCont) { foreach (TroopContainer3d zs in linkedContainers) { if (zs.data == targetCont) { return(true); } } return(false); }
private void Virtualize(UnitSide side, Vector3 position, float range, Dictionary <uint, TroopContainer> containers) { containers.Clear(); var allies = getAllyUnits(side, position, range, allowDead: false, GetSingleUnitTypes(UnitType.Commander)); foreach (var u in allies) { if (!this.TryGetComponent <BaseUnitHealth.Component>(u.id, out var health) || !this.TryGetComponent <GunComponent.Component>(u.id, out var gun) || !this.TryGetComponent <BaseUnitStatus.Component>(u.id, out var status)) { continue; } var rank = status.Value.Rank; if (containers.TryGetValue(rank, out var troop) == false) { troop = new TroopContainer() { Rank = rank }; } var dic = troop.SimpleUnits; var simple = new SimpleUnit(); //var inverse = Quaternion.Inverse(trans.rotation); simple.RelativePos = (u.pos - position).ToFixedPointVector3();//(inverse * (u.pos - trans.position)).ToFixedPointVector3(); simple.RelativeRot = u.rot.ToCompressedQuaternion(); simple.Health = health == null ? 0: health.Value.Health; // todo calc attack and range from GunComponent; //int32 attack = 5; //float attack_range = 6; dic.Add(u.id, simple); troop.SimpleUnits = dic; containers[rank] = troop; } }