Exemplo n.º 1
0
    public ProvinceData(FractionType fraction, Region reg)
    {
        region         = reg;
        this.fraction  = fraction;
        buildings      = new int[buildingsCount];
        BuildingAction = new GameAction[buildingsCount];
        buildings[(int)BuildingType.Infrastructure] = Random.Range(0, 2);
        buildings[(int)BuildingType.Trade]          = Random.Range(0, 2);
        buildings[(int)BuildingType.Walls]          = Random.Range(0, 2);
        int n = maxGarnison / 2 + Random.Range(0, maxGarnison / 2);
        int k = Random.Range(0, n);

        if (reg.owner.melee)
        {
            for (int i = 0; i < k; i++)
            {
                garnison.Add(new Regiment(reg.owner.melee));
            }
        }
        if (reg.owner.ranger)
        {
            for (int i = 0; i < n - k; i++)
            {
                garnison.Add(new Regiment(reg.owner.ranger));
            }
        }
    }
Exemplo n.º 2
0
 public Distance(double distance, TrackType tt, FractionType fractionToUseAsFirst, FractionType fractionToUseAsSecond)
 {
     _distance = distance;
     _tt = tt;
     _fractionToUseAsFirst = fractionToUseAsFirst;
     _fractionToUseAsSecond = fractionToUseAsSecond;
 }
Exemplo n.º 3
0
        private static Dictionary <string, ZoneNpcInfo> LoadNpcs(XElement parent)
        {
            return(parent.Elements("npc").Select(e =>
            {
                string id = e.GetString("id");
                float[] position = e.GetFloatArray("position");
                float[] rotation = e.GetFloatArray("rotation");
                float respawnInterval = e.GetFloat("respawn_interval");
                Difficulty d = (Difficulty)Enum.Parse(typeof(Difficulty), e.Attribute("difficulty").Value);
                Race race = Race.None;
                if (e.HasAttribute("race"))
                {
                    race = (Race)Enum.Parse(typeof(Race), e.Attribute("race").Value);
                }
                FractionType fraction = FractionType.Pirate;
                if (e.HasAttribute("fraction"))
                {
                    fraction = (FractionType)Enum.Parse(typeof(FractionType), e.GetString("fraction"));
                }

                return new ZoneNpcInfo {
                    Id = id,
                    Position = position,
                    Rotation = rotation,
                    RespawnInterval = respawnInterval,
                    Workshop = e.GetEnum <Workshop>("workshop"),
                    Difficulty = d,
                    Race = race,
                    fraction = fraction,
                    name = e.GetString("name"),
                    level = e.GetInt("level"),
                    aiType = LoadAIType(e.Element("ai"))
                };
            }).ToDictionary(npc => npc.Id, npc => npc));
        }
Exemplo n.º 4
0
		private Fraction(Color c, Fraction nfrac, FractionType type, float mult, FractionDifficulty diff)
		{
			Color = c;
			Type = type;
			Difficulty = diff;
			neutralFraction = (Type == FractionType.NeutralFraction) ? this : nfrac;
			Multiplicator = mult;
			BackgroundColor = IsNeutral ? Color.Magenta : ColorMath.Blend(FlatColors.Background, c, 0.25f);
		}
Exemplo n.º 5
0
 private Fraction(Color c, Fraction nfrac, FractionType type, float multBullet, float multLaser, FractionDifficulty diff)
 {
     Color               = c;
     Type                = type;
     Difficulty          = diff;
     neutralFraction     = (Type == FractionType.NeutralFraction) ? this : nfrac;
     BulletMultiplicator = multBullet;
     LaserMultiplicator  = multLaser;
     BackgroundColor     = IsNeutral ? Color.Magenta : ColorMath.Blend(FlatColors.Background, c, 0.25f);
 }
Exemplo n.º 6
0
 Team GetTeamByFraction(FractionType fraction)
 {
     if (fraction == redTeam.FractionType)
     {
         return(redTeam);
     }
     else
     {
         return(blueTeam);
     }
 }
Exemplo n.º 7
0
        private void LoadFromDocument(XDocument document)
        {
            relations = new Dictionary <FractionType, Dictionary <FractionType, FractionRelation> >();

            relations = document.Element("fractions").Elements("fraction").Select(e => {
                var relations = e.Element("relations").Elements("relation").Select(e2 => {
                    FractionType toFraction = (FractionType)Enum.Parse(typeof(FractionType), e2.GetString("to"));
                    FractionRelation rel    = (FractionRelation)Enum.Parse(typeof(FractionRelation), e2.GetString("value"));
                    return(new { FRACTION = toFraction, RELATION = rel });
                }).ToDictionary(obj => obj.FRACTION, obj => obj.RELATION);

                FractionType sourceFraction = (FractionType)Enum.Parse(typeof(FractionType), e.GetString("name"));
                return(new { SOURCEFRACTION = sourceFraction, SOURCERELATIONS = relations });
            }).ToDictionary(obj => obj.SOURCEFRACTION, obj => obj.SOURCERELATIONS);
        }
Exemplo n.º 8
0
 public BotCharacterComponentData(XElement e)
 {
     workshop = (Workshop)Enum.Parse(typeof(Workshop), e.GetString("workshop"));
     level    = e.GetInt("level");
     fraction = (FractionType)Enum.Parse(typeof(FractionType), e.GetString("fraction"));
 }
Exemplo n.º 9
0
 public static FractionRelation RelationTo(this Dictionary <FractionType, FractionRelation> source, FractionType type)
 {
     return(source[type]);
 }
Exemplo n.º 10
0
        //public FractionRelation Relation(FractionType first, FractionType second) {
        //    return relations[first][second];
        //}

        public Dictionary <FractionType, FractionRelation> RelationFor(FractionType type)
        {
            return(relations[type]);
        }
Exemplo n.º 11
0
 public virtual void SetFraction(FractionType inFraction)
 {
     fraction = (int)inFraction;
 }
Exemplo n.º 12
0
        protected virtual bool FindCombatTarget()
        {
            FractionType selfFraction = (FractionType)mCharacter.fraction;

            if (mReturningToStartPosition)
            {
                return(false);
            }

            if (selfFraction == FractionType.BotNeutral)
            {
                return(false);
            }


            var it = (nebulaObject.world as MmoWorld).GetItem((item) => {
                //don't look at self
                if (item.Id == nebulaObject.Id)
                {
                    return(false);
                }
                //don't look invisible items
                if (item.invisible)
                {
                    return(false);
                }

                var itemDamagable = item.GetComponent <DamagableObject>();
                var itemCharacter = item.GetComponent <CharacterObject>();


                if (itemDamagable && itemCharacter)
                {
                    var itemFraction = (FractionType)itemCharacter.fraction;
                    if (nebulaObject.resource.fractionResolver.RelationFor(selfFraction).RelationTo(itemFraction) == FractionRelation.Enemy)
                    {
                        float distance = transform.DistanceTo(item.transform);

                        if (mUseHitProbForAgro)
                        {
                            float hitProb = mWeapon.HitProbTo(item);
                            if (hitProb >= 0.5f && distance < MAX_AGRO)
                            {
                                return(true);
                            }
                        }
                        else
                        {
                            float d = transform.DistanceTo(item.transform);

                            if (isPlanetTurret || isTurret || isOutpost || isFortification)
                            {
                                return(d < mWeapon.optimalDistance);
                            }
                            else
                            {
                                if (d < Mathf.Clamp(0.7f * mWeapon.optimalDistance, MIN_AGRO, MAX_AGRO))
                                {
                                    return(true);
                                }
                            }
                        }
                    }
                }
                return(false);
            });

            if (it)
            {
                mStartPosition = transform.position;
                mTarget.SetTarget(it);
                return(true);
            }
            return(false);
        }
Exemplo n.º 13
0
 public override void SetFraction(FractionType inFraction)
 {
     base.SetFraction(inFraction);
     log.InfoFormat("player character = {0} set fraction = {1}", login, (FractionType)(byte)fraction);
 }
Exemplo n.º 14
0
 static int Type(FractionType fraction)
 {
     return((int)fraction);
 }
Exemplo n.º 15
0
 public static Port GetPort(FractionType fraction) => PrefabData.Ports[(int)fraction];
Exemplo n.º 16
0
 public BotCharacterComponentData(Workshop workshop, int level, FractionType fraction)
 {
     this.workshop = workshop;
     this.level    = level;
     this.fraction = fraction;
 }
Exemplo n.º 17
0
 public BotCharacterComponentData(Hashtable hash)
 {
     workshop = (Workshop)(byte)hash.GetValue <int>((int)SPC.Workshop, (int)Workshop.Arlen);
     level    = hash.GetValue <int>((int)SPC.Level, 0);
     fraction = (FractionType)hash.GetValue <int>((int)SPC.Fraction, (int)FractionType.Friend);
 }
Exemplo n.º 18
0
    public static void Load(out byte SeaLevel, out Texture2D[] landTex, out Texture2D[] landNorm, out byte[] terrain, out byte[] HeightArr, out int[,] provArr, out List <Region> regions, out List <State> states, string path)
    {
        using (BinaryReader reader = new BinaryReader(File.OpenRead(path)))
        {
            SeaLevel = reader.ReadByte();
            int h = reader.ReadByte() * MapMetrics.Tile;
            int w = reader.ReadByte() * MapMetrics.Tile;

            landTex  = new Texture2D[4];
            landNorm = new Texture2D[4];
            for (int i = 0; i < 4; i++)
            {
                landTex[i] = new Texture2D(w, h);
                int pngL = reader.ReadInt32();
                landTex[i].LoadImage(reader.ReadBytes(pngL));

                landNorm[i] = new Texture2D(w, h);
                pngL        = reader.ReadInt32();
                landNorm[i].LoadImage(reader.ReadBytes(pngL));
            }
            terrain = reader.ReadBytes(w * h);

            HeightArr = reader.ReadBytes(h * w);

            byte[] topr = reader.ReadBytes(h * w * 2);
            provArr = new int[h, w];
            for (int i = 0; i < h; i++)
            {
                for (int j = 0; j < w; j++)
                {
                    provArr[i, j] = (topr[(i * w + j) * 2] << 8) + topr[(i * w + j) * 2 + 1];
                }
            }

            regions = new List <Region>();
            int regcount = reader.ReadInt16();
            for (int i = 0; i < regcount; i++)
            {
                regions.Add(new Region());
            }
            for (int i = 0; i < regions.Count; i++)
            {
                regions[i].id       = i;
                regions[i].name     = reader.ReadString();
                regions[i].Capital  = new Vector2Int(reader.ReadInt16(), reader.ReadInt16());
                regions[i].iswater  = reader.ReadBoolean();
                regions[i].portIdto = reader.ReadInt16();
                int l = reader.ReadByte();
                regions[i].neib = new Region[l];
                //regions[i].border = new List<GameObject>[l];
                //regions[i].arrow = new GameObject[l];
                for (int j = 0; j < l; j++)
                {
                    int k = reader.ReadInt16();
                    regions[i].neib[j] = regions[k];
                }
            }
            Texture2D colors = new Texture2D(32, 32);
            colors.LoadImage(File.ReadAllBytes("Assets/Texture/Terrain/StateColor.png"));

            string[] names = File.ReadAllLines("Assets/Textes/States.txt");

            int stcount = reader.ReadInt16();
            states = new List <State>();
            for (int i = 0; i < stcount; i++)
            {
                states.Add(new State());
            }
            for (int i = 0; i < states.Count; i++)
            {
                int a0 = reader.ReadInt16();
                // states[i].originalId = a0;
                if (i == 0)
                {
                    states[i].mainColor = new Color(0, 0, 0, 0);
                }
                else
                {
                    states[i].mainColor = colors.GetPixel(a0 % 32, a0 / 32);
                }
                states[i].name = names[a0];
                states[i].flag = new Texture2D(128, 128);
                states[i].flag.LoadImage(File.ReadAllBytes("Assets/Texture/flags/(" + a0 + ").png"));

                states[i].Capital  = regions[reader.ReadInt16()];
                states[i].fraction = (FractionType)reader.ReadByte();

                int l = reader.ReadInt16();
                for (int j = 0; j < l; j++)
                {
                    int k = reader.ReadInt16();
                    states[i].regions.Add(regions[k]);
                    regions[k].owner = states[i];
                }
            }

            for (int i = 0; i < regions.Count; i++)
            {
                FractionType frac = regions[i].owner.fraction;
                regions[i].data = new ProvinceData(frac, regions[i]);
                regions[i].data.Load(reader);
            }
        }
    }