Exemplo n.º 1
0
        //private Ship selectedShip;

        //public Ship SelectedShip
        //{
        //    get { return selectedShip; }
        //    set { selectedShip = value; }
        //}

        public Faction(World world, FactionControllerType controllerType, int factionID, Color factionColor, string name)
        {
            this.world          = world;
            this.controllerType = controllerType;
            this.factionColor   = factionColor;
            this.factionID      = factionID;
            this.name           = name;
        }
Exemplo n.º 2
0
        public void InitShip(int faction, Color color, string name, FactionControllerType type)
        {
            if (faction == 1)
            {
                Color c = color;
                if (f2 != null)
                {
                    Vector3 c1 = c.ToVector3();
                    Vector3 c2 = f2.FactionColor.ToVector3();
                    if (Vector3.Distance(c1, c2) < 0.1f)
                    {
                        if (Vector3.Distance(c2, Color.Red.ToVector3()) >= 0.1f)
                        {
                            c = Color.Red;
                        }
                        else
                        {
                            c = Color.Green;
                        }
                    }
                }
                //test
                f1 = new Faction(this, type, 1, color, name);
                factions.Add(f1);

                ships.Add(new Ship(this, new Vector2(-768, -102.4f), 90f, f1, 1));
                f1.Ships.Add(ships.LatestAddedItem);
                ships.Add(new Ship(this, new Vector2(-768, -51.2f), 90f, f1, 2));
                f1.Ships.Add(ships.LatestAddedItem);
                ships.Add(new Ship(this, new Vector2(-768, 0), 90f, f1, 3));
                f1.Ships.Add(ships.LatestAddedItem);
                ships.Add(new Ship(this, new Vector2(-768, 51.2f), 90f, f1, 4));
                f1.Ships.Add(ships.LatestAddedItem);
                ships.Add(new Ship(this, new Vector2(-768, 102.4f), 90f, f1, 5));
                f1.Ships.Add(ships.LatestAddedItem);
            }
            else if (faction == 2)
            {
                Color c = color;
                if (f1 != null)
                {
                    Vector3 c1 = c.ToVector3();
                    Vector3 c2 = f1.FactionColor.ToVector3();
                    if (Vector3.Distance(c1, c2) < 0.1f)
                    {
                        if (Vector3.Distance(c2, Color.Blue.ToVector3()) >= 0.1f)
                        {
                            c = Color.Blue;
                        }
                        else
                        {
                            c = Color.Yellow;
                        }
                    }
                }
                //test
                f2 = new Faction(this, type, 2, c, name);
                factions.Add(f2);

                ships.Add(new Ship(this, new Vector2(768, -102.4f), -90f, f2, 6));
                f2.Ships.Add(ships.LatestAddedItem);
                ships.Add(new Ship(this, new Vector2(768, -51.2f), -90f, f2, 7));
                f2.Ships.Add(ships.LatestAddedItem);
                ships.Add(new Ship(this, new Vector2(768, 0f), -90f, f2, 8));
                f2.Ships.Add(ships.LatestAddedItem);
                ships.Add(new Ship(this, new Vector2(768, 51.2f), -90f, f2, 9));
                f2.Ships.Add(ships.LatestAddedItem);
                ships.Add(new Ship(this, new Vector2(768, 102.4f), -90f, f2, 10));
                f2.Ships.Add(ships.LatestAddedItem);
            }
            //by 刘欣 李翔
            collector.GetPlayerInfo(faction, color, name);
        }