Beispiel #1
0
    public Spawner(GamePrefabs prefabs)
    {
        _cache = new SimpleCache <RelativeSpaceObject> [System.Enum.GetNames(typeof(ESpaceObjects)).Length];

        _cache[(int)ESpaceObjects.Wreck]       = new SimpleCache <RelativeSpaceObject>(prefabs.Wreck, 15);
        _cache[(int)ESpaceObjects.WreckLoco]   = new SimpleCache <RelativeSpaceObject>(prefabs.WreckLoco, 4);
        _cache[(int)ESpaceObjects.WreckStatic] = new SimpleCache <RelativeSpaceObject>(prefabs.WreckStatic, 7);
        _cache[(int)ESpaceObjects.Jammer]      = new SimpleCache <RelativeSpaceObject>(prefabs.Jammer, 3);
        _cache[(int)ESpaceObjects.AlienSmall]  = new SimpleCache <RelativeSpaceObject>(prefabs.AlienSmall, 7);
        _cache[(int)ESpaceObjects.AlienBig]    = new SimpleCache <RelativeSpaceObject>(prefabs.AlienBig, 6);
        _cache[(int)ESpaceObjects.AlienShield] = new SimpleCache <RelativeSpaceObject>(prefabs.AlienShield, 5);
        _cache[(int)ESpaceObjects.Rocket]      = new SimpleCache <RelativeSpaceObject>(prefabs.Rocket, 8);
        _cache[(int)ESpaceObjects.Bullet]      = new SimpleCache <RelativeSpaceObject>(prefabs.Bullet, 10);

        _destroyDelegates = new System.Action <RelativeSpaceObject> [_cache.Length];

        for (int i = 0; i < _cache.Length; i++)
        {
            var cache = _cache[i];
            var index = i;

            _destroyDelegates[i] = (x) =>
            {
                cache.Push(x);
                x.OnDestroy -= _destroyDelegates[index];
                x.OnReward  -= OnReward;
                LiveObjects.Remove(x);
            };
        }
    }
    public Spawner(GamePrefabs prefabs)
    {
        _cache = new SimpleCache<RelativeSpaceObject>[System.Enum.GetNames(typeof(ESpaceObjects)).Length];

        _cache[(int)ESpaceObjects.Wreck] = new SimpleCache<RelativeSpaceObject>(prefabs.Wreck, 15);
        _cache[(int)ESpaceObjects.WreckLoco] = new SimpleCache<RelativeSpaceObject>(prefabs.WreckLoco, 4);
        _cache[(int)ESpaceObjects.WreckStatic] = new SimpleCache<RelativeSpaceObject>(prefabs.WreckStatic, 7);
        _cache[(int)ESpaceObjects.Jammer] = new SimpleCache<RelativeSpaceObject>(prefabs.Jammer, 3);
        _cache[(int)ESpaceObjects.AlienSmall] = new SimpleCache<RelativeSpaceObject>(prefabs.AlienSmall, 7);
        _cache[(int)ESpaceObjects.AlienBig] = new SimpleCache<RelativeSpaceObject>(prefabs.AlienBig, 6);
        _cache[(int)ESpaceObjects.AlienShield] = new SimpleCache<RelativeSpaceObject>(prefabs.AlienShield, 5);
        _cache[(int)ESpaceObjects.Rocket] = new SimpleCache<RelativeSpaceObject>(prefabs.Rocket, 8);
        _cache[(int)ESpaceObjects.Bullet] = new SimpleCache<RelativeSpaceObject>(prefabs.Bullet, 10);

        _destroyDelegates = new System.Action<RelativeSpaceObject>[_cache.Length];

        for (int i = 0; i < _cache.Length; i++)
        {
            var cache = _cache[i];
            var index = i;

            _destroyDelegates[i] = (x) =>
            {
                cache.Push(x);
                x.OnDestroy -= _destroyDelegates[index];
                x.OnReward -= OnReward;
                LiveObjects.Remove(x);
            };
        }
    }
Beispiel #3
0
        public Asset_Explosion(ModAssetBundle modAssetBundle)
        {
            bigExplosionEffect       = modAssetBundle.LoadAsset <GameObject>("BigExplosion");
            smokeExplosionEffect     = modAssetBundle.LoadAsset <GameObject>("DarkSmoke");
            largeExplosionEffect     = GamePrefabs.InstantiateExplosion(GamePrefabs.ExplosionType.Large);
            smallExplosionEffect     = GamePrefabs.InstantiateExplosion(GamePrefabs.ExplosionType.Small);
            fireworkeExplosionEffect = GamePrefabs.InstantiateExplosion(GamePrefabs.ExplosionType.Firework);

            //AssetManager.SetObjectScale(bigExplosionEffect, MordenFirearmKitBlockMod.Configuration.GetValue<Vector3>("BigExplosionEffectScale"));
            bigExplosionEffect.transform.localScale = Vector3.Scale(bigExplosionEffect.transform.localScale, MordenFirearmKitBlockMod.Configuration.GetValue <Vector3>("BigExplosionEffectScale"));
            bigExplosionEffect.transform.FindChild("Debris").localRotation = Quaternion.AngleAxis(UnityEngine.Random.Range(0f, 360f), Vector3.up);
            bigExplosionEffect.transform.localRotation = Quaternion.AngleAxis(90f, Vector3.left);
            bigExplosionEffect.SetActive(false);

            AssetManager.SetObjectScale(smokeExplosionEffect, MordenFirearmKitBlockMod.Configuration.GetValue <Vector3>("SmokeExplosionEffectScale"));
            smokeExplosionEffect.SetActive(false);

            AssetManager.SetObjectScale(largeExplosionEffect, MordenFirearmKitBlockMod.Configuration.GetValue <Vector3>("LargeExplosionEffectScale"));
            largeExplosionEffect.SetActive(false);

            AssetManager.SetObjectScale(smallExplosionEffect, MordenFirearmKitBlockMod.Configuration.GetValue <Vector3>("SmallExplosionEffectScale"));
            smallExplosionEffect.SetActive(false);

            AssetManager.SetObjectScale(fireworkeExplosionEffect, MordenFirearmKitBlockMod.Configuration.GetValue <Vector3>("FireworkExplosionEffectScale"));
            fireworkeExplosionEffect.SetActive(false);

            bigExplosionEffect.AddComponent <DestroyIfEditMode>();
            smokeExplosionEffect.AddComponent <DestroyIfEditMode>();
        }
Beispiel #4
0
        public OldMatchController(GamePrefabs prefabs, GlobalInventoryModel globalInventory, OldHandState playerHand, OldHandState opponentHand, MatchStyleOld style, MatchStyleOptions options)
        {
            this.CurrentStyle = style;
            this.MatchOptions = options;

            this.globalInventory = globalInventory;
            this.prefabs         = prefabs;
            this.Player          = new PlayerHandController(
                playerHand,
                prefabs.PlayerRockCardPrefab,
                prefabs.PlayerPaperCardPrefab,
                prefabs.PlayerScissorsCardPrefab,
                prefabs.CardBackground,
                prefabs.StarPrefab);

            this.Opponent = new OpponentHandController(
                opponentHand,
                prefabs.OpponentRockCardPrefab,
                prefabs.OpponentPaperCardPrefab,
                prefabs.OpponentScissorsCardPrefab,
                prefabs.CardBackground,
                prefabs.StarPrefab);

            this.Player.GenerateCards(prefabs.PlayerCardRootObject, new UnityEngine.Vector3(-7.25f, -2.5f, 0f), HandControllerBase.HandLayout.RightToLeft);
            this.Opponent.GenerateCards(prefabs.OpponentCardRootObject, new UnityEngine.Vector3(4.6f, -2.2f, 0f), HandControllerBase.HandLayout.LeftToRight);

            this.Player.GenerateStars(prefabs.PlayerStarRootObject, new Vector3(-3.15f, -5.45f, 0f));
            this.Opponent.GenerateStars(prefabs.OpponentStarRootObject, new Vector3(3.25f, -5.45f, 0f));

            this.Player.CardChosenEvent   += OnPlayerCardChosen;
            this.Opponent.CardChosenEvent += OnOpponentCardChosen;
        }
Beispiel #5
0
 public static GameObject GetPrefab(GamePrefabs prefab)
 {
     GameObject go = null;
     switch (prefab)
     {
         case GamePrefabs.Cell:
             go = SkinResources.CellPrefab;
             break;
         case GamePrefabs.Zombie:
             go = SkinResources.ZombiePrefab;
             break;
         case GamePrefabs.Minotaur:
             go = SkinResources.MinotaurPrefab;
             break;
         case GamePrefabs.Mage:
             go = SkinResources.MagePrefab;
             break;
         case GamePrefabs.SimpleTower:
             go = SkinResources.SimpleTowerPrefab;
             break;
         case GamePrefabs.SplashTower:
             go = SkinResources.SplashTowerPrefab;
             break;
         case GamePrefabs.FrozenTower:
             go = SkinResources.FrozenTowerPrefab;
             break;
         case GamePrefabs.Bullet:
             go = SkinResources.BulletPrefab;
             break;
         case GamePrefabs.Freeze:
             go = SkinResources.FreezePrefab;
             break;
         case GamePrefabs.Splash:
             go = SkinResources.SplashPrefab;
             break;
         case GamePrefabs.Healthbar:
             go = SkinResources.HealthbarPrefab;
             break;
         case GamePrefabs.Manabar:
             go = SkinResources.ManabarPrefab;
             break;
         case GamePrefabs.HealingEffect:
             go = SkinResources.HealingEffectPrefab;
             break;
         case GamePrefabs.FreezEffect:
             go = SkinResources.FreezEffectPrefab;
             break;
         case GamePrefabs.EnemyDropCost:
             go = SkinResources.EnemyDropCostPrefab;
             break;
         case GamePrefabs.FireEffect:
             go = SkinResources.FireEffectPrefab;
             break;
     }
     return go;
 }
Beispiel #6
0
 public GameController(GamePrefabs prefabs)
 {
     this.SetupNewGame();
     this.random  = new Random();
     this.prefabs = prefabs;
     this.prefabs.ReturnHomeButton.onClick.AddListener(OnReturnHomeClicked);
     this.prefabs.RematchButton.onClick.AddListener(OnRematchClicked);
     this.prefabs.SinglePlayerButton.onClick.AddListener(OnStartSinglePlayerClicked);
     this.prefabs.MatchResultFrame.SetActive(false);
     this.prefabs.MatchSetupFrame.SetActive(true);
 }
Beispiel #7
0
        public RoomManager(IRoomController controller, UserId currentUserId, GamePrefabs prefabs)
        {
            this.prefabs       = prefabs;
            this.currentUserId = currentUserId;
            this.Controller    = controller;
            this.MatchList     = new List <MatchManager>();

            //this.prefabs.StartMatchButton.onClick.AddListener(OnStartMatchClicked);
            Controller.MatchCreatedEvent += OnMatchCreated;
            Controller.RoomStartedEvent  += OnRoomStarted;
            Controller.RoomEndedEvent    += OnRoomEnded;
            Controller.UserJoinedEvent   += OnUserJoined;
            Controller.UserLeftEvent     += OnUserLeft;
            this.type = GameType.Single;

            this.prefabs.SetupMatchButton.onClick.AddListener(OnSetupMatchClicked);
            this.prefabs.ReturnToListButton.onClick.AddListener(OnReturnToListClicked);
            this.prefabs.CreateMatchButton.onClick.AddListener(OnCreateMatchClicked);

            //TODO: Move AI management
            if (controller is LocalRoomController)
            {
                this.aiPlayers = 5;

                this.aiList = new List <UserState>();
                if (this.Controller is LocalRoomController Local)
                {
                    this.currentUser = Local.AddPlayer(this.currentUserId);
                    for (int i = 0; i < aiPlayers; i++)
                    {
                        var user = new UserId();
                        aiList.Add(Local.AddPlayer(new UserId()));
                    }
                }

                for (int i = 0; i < 3; i++)
                {
                    Controller.CreateMatch(new MatchOptions()
                    {
                        Name        = "Match " + i.ToString(),
                        Style       = MatchStyle.Rounds,
                        Rounds      = 3,
                        TimerLength = 10f,
                    });
                }
            }

            var existing = this.Controller.GetMatches();

            foreach (var match in existing)
            {
                this.OnMatchCreated(this, (this.Controller, match));
            }
        }
Beispiel #8
0
        public MatchManager(IMatchController match, UserId localUser, GamePrefabs prefabs)
        {
            this.localUser = localUser;
            this.prefabs   = prefabs;
            this.Match     = match;

            this.Match.MatchStartedEvent += OnMatchStarted;
            this.Match.MatchEndedEvent   += OnMatchEnded;
            this.Match.UserJoinedEvent   += OnUserJoined;
            this.Match.UserLeftEvent     += OnUserLeft;
            this.Match.RoundCreatedEvent += OnRoundCreated;
        }
Beispiel #9
0
 void Awake()
 {
     instance = this;
 }
Beispiel #10
0
 void Awake()
 {
     instance = this;
 }
Beispiel #11
0
    // Start is called before the first frame update
    private void Start()
    {
        this.prefabs = new GamePrefabs()
        {
            InfoText = infoText,
            OpponentCardRootObject     = OpponentCardRoot,
            OpponentPaperCardPrefab    = OpponentPaper,
            OpponentRockCardPrefab     = OpponentRock,
            OpponentScissorsCardPrefab = OpponentScissors,
            PlayerCardRootObject       = PlayerCardRoot,
            PlayerPaperCardPrefab      = PlayerPaper,
            PlayerRockCardPrefab       = PlayerRock,
            PlayerScissorsCardPrefab   = PlayerScissors,
            CardBackground             = CardBackground,
            RockCounter            = RockCounter,
            PaperCounter           = PaperCounter,
            ScissorsCounter        = ScissorsCounter,
            StarPrefab             = Star,
            OpponentStarRootObject = OpponentStarRoot,
            PlayerStarRootObject   = PlayerStarRoot,
            DefeatFrame            = DefeatFrame,
            RematchButton          = RematchButton,
            ReturnHomeButton       = ReturnHomeButton,
            VictoryFrame           = VictoryFrame,
            MatchResultFrame       = MatchResultFrame,
            MatchSetupFrame        = MatchSetupFrame,
            MultiPlayerButton      = MultiPlayerButton,
            SinglePlayerButton     = SinglePlayerButton,
            SelectGameTypeFrame    = SelectGameTypeFrame,
            StartMatchButton       = StartMatchButton,
            CounterFrame           = CounterFrame,
            LoginButton            = LoginButton,
            LoginFrame             = LoginFrame,
            PasswordText           = PasswordText,
            UsernameText           = UsernameText,
            OpponentCardController = OpponentCardController,
            OpponentStarController = OpponentStarController,
            PlayerCardController   = PlayerCardController,
            PlayerStarController   = PlayerStarController,
            MatchListFrame         = MatchListFrame,
            MatchListEntryItem     = MatchListEntryItem,
            RoomLobbyFrame         = RoomLobbyFrame,
            MatchListContent       = MatchListContent,
            SetupMatchButton       = SetupMatchButton,
            ReturnToListButton     = ReturnToListButton,
            CreateMatchButton      = CreateMatchButton,
            AllCardsToggle         = AllCardsToggle,
            MessagePrefab          = MessagePrefab,
            RoundCount             = RoundCount,
            RoundsToggle           = RoundsToggle,
            TimerLength            = TimerLength,
            MatchName = MatchName,
        };

        this.prefabs.ReturnHomeButton.onClick.AddListener(OnReturnHomeClicked);
        this.prefabs.RematchButton.onClick.AddListener(OnRematchClicked);
        this.prefabs.SinglePlayerButton.onClick.AddListener(OnSinglePlayerClicked);
        this.prefabs.MultiPlayerButton.onClick.AddListener(OnMultiPlayerClicked);
        this.prefabs.LoginButton.onClick.AddListener(OnLoginClicked);

        this.prefabs.MatchListFrame.SetActive(false);
        this.prefabs.MatchResultFrame.SetActive(false);
        this.prefabs.MatchSetupFrame.SetActive(false);
        this.prefabs.SelectGameTypeFrame.SetActive(false);
        this.prefabs.CounterFrame.SetActive(false);
        this.prefabs.LoginFrame.SetActive(true);
    }
Beispiel #12
0
 public Builder(GamePrefabs prefabs, Level level, Transform container)
 {
     this.prefabs   = prefabs;
     this.level     = level;
     this.container = container;
 }
 void Awake()
 {
     if (inst == null)
         inst = this;
 }
Beispiel #14
0
 public static void Find()
 {
     GameObject go =  GameObject.Find("Game");
     gps = go.GetComponent<GamePrefabs>();
 }
Beispiel #15
0
    static public void Find()
    {
        GameObject go = GameObject.Find("Game");

        gps = go.GetComponent <GamePrefabs>();
    }