Пример #1
0
        public GameObject Create(string type, EFaction faction, ETeam team)
        {
            EBuildingType buildingType = (EBuildingType)Enum.Parse(typeof(EBuildingType), type);

            GameObject      go       = new GameObject();
            CSpriteRenderer sr       = new CSpriteRenderer(SpriteContainer.Instance.SpriteSheet["GrayTent"]);
            CBuilding       building = new CBuilding(buildingType, faction, team);
            CStats          stats    = new CStats();

            sr.LayerDepth         = 0.3f;
            sr.OriginPositionEnum = EOriginPosition.TopLeft;
            sr.OffSet             = new Vector2(-1 * 128 / 2, -3 * 128 / 2);
            go.Transform.Scale   *= 0.5f;

            go.AddComponent <CSpriteRenderer>(sr);
            go.AddComponent <CBuilding>(building);
            go.AddComponent <CStats>(stats);

            switch (buildingType)
            {
            case EBuildingType.TownHall:
                break;

            case EBuildingType.ArcheryRange:
                break;

            case EBuildingType.Blacksmith:
                break;

            case EBuildingType.Tower:
                break;

            case EBuildingType.Barracks:
                break;

            case EBuildingType.GatheringStation:
                break;

            case EBuildingType.Field:
                sr.OffSet = new Vector2(0 * 128 / 2, 0 * 128 / 2);
                sr.SetSprite(SpriteContainer.Instance.TileSprite.Wheatfield);
                break;

            default:
                break;
            }

            if (buildingType != EBuildingType.Field)
            {
                switch (team)
                {
                case ETeam.Team01:
                    sr.Color = Color.Red;
                    break;

                case ETeam.Team02:
                    sr.Color = Color.Blue;
                    break;

                case ETeam.Team03:
                    sr.Color = Color.Green;
                    break;

                case ETeam.Team04:
                    sr.Color = Color.Yellow;
                    break;

                case ETeam.Team05:
                    break;

                case ETeam.Team06:
                    break;

                case ETeam.Team07:
                    break;

                case ETeam.Team08:
                    break;

                default:
                    break;
                }
            }

            return(go);
        }
Пример #2
0
        public GameObject Create(string type, EFaction faction, ETeam team)
        {
            // Main GameObject
            GameObject      go            = new GameObject();
            CSpriteRenderer sr            = new CSpriteRenderer(SpriteContainer.Instance.Pixel);
            CAnimator       animator      = new CAnimator();
            CUnit           unit          = new CUnit(team, (EUnitType)Enum.Parse(typeof(EUnitType), type), faction);
            CMove           move          = new CMove();
            CStats          stats         = new CStats();
            CAstar          astar         = new CAstar(unit);
            CSelectable     canBeSelected = new CSelectable();
            CShadow         shadow        = new CShadow();

            go.AddComponent <CUnit>(unit);
            go.AddComponent <CMove>(move);
            go.AddComponent <CStats>(stats);
            go.AddComponent <CShadow>(shadow);
            go.AddComponent <CSpriteRenderer>(sr);
            go.AddComponent <CAnimator>(animator);
            go.AddComponent <CSelectable>(canBeSelected);
            go.AddComponent <CAstar>(astar);

            switch (team)
            {
            case ETeam.Team01:
                sr.Color = Color.LightPink;
                break;

            case ETeam.Team02:
                sr.Color = Color.LightBlue;
                break;

            case ETeam.Team03:
                sr.Color = Color.LightGreen;
                break;

            case ETeam.Team04:
                sr.Color = Color.Yellow;
                break;

            case ETeam.Team05:
                break;

            case ETeam.Team06:
                break;

            case ETeam.Team07:
                break;

            case ETeam.Team08:
                break;

            default:
                break;
            }

            sr.LayerDepth       = 0.3f;
            sr.OffSet           = new Vector2(-0.75f * 128, -0.9f * 128);
            go.Transform.Scale *= 1.0f;

            return(go);
        }