//Initialize stuff here, for the pre-loading scene
    public void Awake()
    {
        DebugLogger.Log("GameManager awake begins", Enum.LoggerMessageType.Important);
        gameState = GameState.Preloading;

        if (_instance == null)
        {
            _instance = this;
        }

        entitySpawner = GetComponent <EntitySpawner>();

        players = new List <GameObject>();

        timerManager = GetComponent <TimerManager>();
        if (timerManager != null)
        {
            timerManager.timerLocked = true;
            DebugLogger.Log("TimerManager initialized for GameManager", Enum.LoggerMessageType.Important);
        }



        DontDestroyOnLoad(gameObject);
        DebugLogger.Log("GameManager awake done", Enum.LoggerMessageType.Important);
    }
Example #2
0
        public void Start()
        {
            var container = ContainerSingletone.Container;
            var boundaryCenterCoordinate = Plane.transform.position;
            var boundaryScale = Plane.transform.localScale;
            var spawner1=new EntitySpawner();

            container.BuildUp(spawner1);
            spawner1.Start(SpawnerPlace1.transform.position);

            var spawner2 = new EntitySpawner();
            container.BuildUp(spawner2);
            spawner2.Start(SpawnerPlace2.transform.position);

            var spawner3 = new EntitySpawner();
            container.BuildUp(spawner3);
            spawner3.Start(SpawnerPlace3.transform.position);

            var scoreManager = container.Resolve<IScoreManager>();

            var audioPlayer = container.Resolve<IAudioPlayer> ();
            audioPlayer.PlayLoop("MainTheme");
            scoreManager.ScoreManipulator = _scorePlaneManuManipulator;
            _countdownTimer = container.Resolve<ICountdownTimer>();
            _countdownTimer.StartCountdown(30f, ShowMenu);
            _scorePrinter = container.Resolve<IScorePrinter> ();
            _scorePrinter.CorrectScorePlace = CorrectScorePlace;
            _scorePrinter.IncorrectScorePlace = IncorrectScorePlace;
            _scorePrinter.FontSize = fontSize;
            _menuButtonFactory = container.Resolve<IMenuButtonFactory>();
            BuildSelectedCharacter ();
            BuildAdditionalButton();
        }
Example #3
0
    protected override void DoActivate(LevelRoom room)
    {
        int num = 0;

        for (int i = this.trackEnts.Count - 1; i >= 0; i--)
        {
            Entity entity = this.trackEnts[i];
            this.trackEnts[i] = null;
            if (EntitySpawner.IsValid(entity))
            {
                entity.Deactivate();
                num++;
            }
        }
        this.totalSpawned = 0;
        this.timer        = this._delay;
        base.enabled      = this._startEnabled;
        if (num > 0)
        {
            UnityEngine.Debug.LogWarning(string.Concat(new object[]
            {
                base.name,
                " had ",
                num,
                " active ents"
            }), this);
        }
    }
 public void Awake()
 {
     if (_instance == null)
     {
         _instance = this;
     }
 }
Example #5
0
    private static void SpawnLevel(int level)
    {
        Texture2D image        = Resources.Load <Texture2D>("level" + level);
        var       widthFactor  = Constants.MAX_WORLD_SIZE / image.width;
        var       heightFactor = Constants.MAX_WORLD_SIZE / image.height;

        for (int i = 0; i < image.width; i++)
        {
            for (int j = 0; j < image.height; j++)
            {
                Color pixel = image.GetPixel(i, j);
                if (pixel == Color.black) //Islands
                {
                    EntitySpawner.SpawnIsland(Utils.getCenterOfVectorFieldArea(i * widthFactor, j * heightFactor));
                }
                else if (pixel == Color.green)   //Boat
                {
                    EntitySpawner.SpawnBoat(Utils.getCenterOfVectorFieldArea(i * widthFactor, j * heightFactor));
                }
                else if (pixel == Color.red)   //Goal
                {
                    EntitySpawner.SpawnGoal(Utils.getCenterOfVectorFieldArea(i * widthFactor, j * heightFactor));
                }
            }
        }
    }
        public void Interpret(INetworkMediator netMediator, EndPoint sender, IMessage message)
        {
            var           msg    = (SpawnEntityMessage)message;
            IEngineFacade engine = (IEngineFacade)netMediator.EngineProxy;

            EntitySpawner.SpawnEntityFromMessage(engine, msg);
        }
Example #7
0
    void Awake()
    {
        // Get local components.
        rigidBody = GetComponent <Rigidbody>();

        ballPrefab = (GameObject)Resources.Load("Prefabs/BallPrefab");

        spawner = GameObject.FindGameObjectWithTag("EntitySpawner").GetComponent <EntitySpawner>();

        engineHumSound      = AddAudio(engineHumClip, true, true, .2f);
        collisionSound      = AddAudio(collisionClip, false, false, 1f);
        proximityAlertSound = AddAudio(proximityAlertClip, true, true, .5f);
        ballSinkSound       = AddAudio(ballSinkClip, false, false, 1);

        gameController = GameObject.FindGameObjectWithTag("GameController").GetComponent <GameController>();

        GameController.GameEndedEvent   += onGameEnded;
        GameController.GamePausedEvent  += onGamePaused;
        GameController.GameResumedEvent += onGameResumed;
        BallController.BallSunkEvent    += onBallSunk;

        engineSoundStartVolume = engineHumSound.volume;

        CurrentSpeed = baseSpeed;

        shipStartRotation = ship.transform.localRotation;

        currentDamage = 0;
    }
Example #8
0
        public SpawnCharacter(SpawnCharacterAction config, EntitySpawner entitySpawner, Character caster,
                              TemplateArgs args, Environment environment, SkillId skillId,
                              HeroAndMonsterConfig hamc)
        {
            this.config        = config;
            this.entitySpawner = entitySpawner;
            this.caster        = caster;
            this.args          = args;
            this.environment   = environment;
            this.skillId       = skillId;
            this.hamc          = hamc;

            entityGroupOfCaster = caster.GameObject().GetComponent <EntityReference>().Entity.Group;
            FrameAndSecondsConverter fasc = FrameAndSecondsConverter._30Fps;

            spawnDelay = fasc.FramesToSeconds(config.delay);
            vfxDelay   = fasc.FramesToSeconds(config.vfxDelay);
            defaultEntityGroupOfMinion = hamc.FindBasicStats(new CharacterId(config.groupId, config.subId)).team;

            if (config.spawnCount > 0)
            {
                Vector3 spawnPosition = CalculateSpawnPosition();
                spawnPositions.Add(spawnPosition);
                if (spawnDelay <= 0)
                {
                    Spawn(spawnPosition);
                }

                if (vfxDelay <= 0)
                {
                    PlayVfx(spawnPosition);
                }
            }
        }
Example #9
0
 void PlaceWorldEntity()
 {
     if (validPosition)
     {
         EntitySpawner.SpawnEntity(GameWorld.LocalPlayer.Player_Toolbar.SelectedSlot.SlotEntityReferenceData, GetHitPosition());
         SoundSystem.PlaySound2D("item_place01");
     }
 }
Example #10
0
 public SkillLoopableElementFactory(Environment environment,
                                    ModifierInfoFactory modifierInfoFactory,
                                    EntitySpawner entitySpawner, HeroAndMonsterConfig hamc)
 {
     this.environment         = environment;
     this.modifierInfoFactory = modifierInfoFactory;
     this.entitySpawner       = entitySpawner;
     this.hamc = hamc;
 }
Example #11
0
    void OnEntitySpawn(EntitySpawner aSpawner, M8.EntityBase ent)
    {
        if (growth > 0)
        {
            var mucusForm = (EntityMucusForm)ent;

            mucusForm.SetGrow(growth);
        }
    }
Example #12
0
    void Start()
    {
        text = GetComponent <Text>();
        GameController.ScoreChangedEvent += onScoreChanged;

        entitySpawner = GameObject.FindGameObjectWithTag("EntitySpawner").GetComponent <EntitySpawner>();

        text.text = entitySpawner.MaxNumGoals.ToString();
    }
Example #13
0
    private WaveManager InitializeEntitySpawner()
    {
        GameObject entitySpawner = SRResources.Core.Base.EntitySpawner.Instantiate();

        entitySpawner.name             = "entitySpawner";
        entitySpawner.transform.parent = this.gameObject.transform;
        _entitySpawner = entitySpawner.GetComponent <EntitySpawner>();
        _entitySpawner.InitializeSpawner(this);
        return(this);
    }
Example #14
0
    void SpawnEntities()
    {
        const bool spawnEntitiesOnStart = true;

        if (spawnEntitiesOnStart)
        {
            EntitySpawner.SpawnEntity(new EntityReferenceData(2), new float3(-3.5f, .5f, -4.5f));
            Database.Instance.StartCoroutine(InserterSpawnDelay());
        }
    }
Example #15
0
 void RemoveWorldEntity()
 {
     if (hit.collider != null)
     {
         EntityCollider entityCollider = hit.collider.GetComponent <EntityCollider>();
         if (entityCollider != null)
         {
             EntitySpawner.DestroyEntity(entityCollider.LinkedEntity);
         }
     }
 }
Example #16
0
    public static void NewGame(int level = 1)
    {
        Debug.Log("Level: " + level);
        SpawnLevel(level);
        EntitySpawner.SpawnParticles();

        Time.timeScale = 1;
        GameObject.Find("GameStatusText").GetComponent <Text>().text = "";

        EntitySpawner.SpawnGameState(level);
    }
Example #17
0
 void Awake()
 {
     FixedEntities            = new Dictionary <Vec2i, List <int> >();
     FixedEntities_           = new Dictionary <int, Entity>();
     LoadedEntities           = new List <LoadedEntity>();
     LoadedChunks             = new List <Vec2i>();
     EntitySpawner            = new EntitySpawner(this);
     NearEntityChunks         = new Dictionary <Vec2i, List <Entity> >();
     LoadedEntityChunks       = new Dictionary <Vec2i, List <Entity> >();
     CurrentWorldCombatEvents = new List <WorldCombat>();
 }
Example #18
0
 protected override void DoDeactivate(LevelRoom room)
 {
     for (int i = this.trackEnts.Count - 1; i >= 0; i--)
     {
         Entity entity = this.trackEnts[i];
         if (EntitySpawner.IsValid(entity))
         {
             this.trackEnts[i] = null;
             entity.Deactivate();
         }
     }
 }
Example #19
0
 static void AddToList(List <Entity> ents, Entity ent)
 {
     for (int i = ents.Count - 1; i >= 0; i--)
     {
         if (!EntitySpawner.IsValid(ents[i]))
         {
             ents[i] = ent;
             return;
         }
     }
     ents.Add(ent);
 }
    private void SpawnOnServer()
    {
        var msg = _msgPool.Get();

        msg.Id       = _runningId++;
        msg.PrefabId = _prefabId;
        msg.Position = new Vector3(Random.Range(-3.0f, 3.0f), Random.Range(-3.0f, 3.0f), Random.Range(-3.0f, 3.0f));
        msg.Rotation = Quaternion.Euler(Random.Range(0.0f, 360.0f), Random.Range(0.0f, 360.0f), Random.Range(0.0f, 360.0f));
        msg.Scale    = new Vector3(Random.Range(0.5f, 3.0f), Random.Range(0.5f, 3.0f), Random.Range(0.5f, 3.0f));
        EntitySpawner.SpawnEntityFromMessage(_engine, msg);            // Spawn for ourselves locally
        _engine.NetworkMediator.SendMessage(msg);
    }
Example #21
0
    Vector3 OppositeRand(Vector3 P)
    {
        Vector3 vector = this.LinearRand();
        int     num    = 10;
        float   num2   = (this._positionDist > 0f) ? this._positionDist : (UnityEngine.Random.Range(0.75f, 1.25f) * this._spawnBounds.extents.magnitude);

        while (EntitySpawner.Dist(P, vector) < num2 && --num > 0)
        {
            vector = this.LinearRand();
        }
        return(vector);
    }
Example #22
0
 protected override void OnAwake()
 {
     if (spawner == null)
     {
         spawner = GetComponent<EntitySpawner>();
     }
     if (spawner != null)
     {
         spawner.OnSpawned += OnPoliceSpawned;
         spawner.autoActivateOnStart = false;
     }
 }
Example #23
0
    Entity DoSpawn()
    {
        Entity entity = this.MakeEntity();

        this.totalSpawned++;
        EntitySpawner.AddToList(this.trackEnts, entity);
        entity.LocalEvents.DeactivateListener += this.onDeactivate;
        if (this.OnSpawnedEntity != null)
        {
            this.OnSpawnedEntity(entity);
        }
        EventListener.EntitySpawn(entity, true);         // Invoke custom event
        return(entity);
    }
        public void Interpret(INetworkMediator netMediator, EndPoint sender, IMessage message)
        {
            var  m    = (CreatePlayerMessage)message;
            bool isMe = netMediator.SocketFacade.NetPlayerId.Equals(m.OwningPlayer);

            if (!isMe)
            {
                m.PrefabId = m.ProxyPrefabId;
            }
            IEngineFacade engine = (IEngineFacade)netMediator.EngineProxy;
            var           e      = EntitySpawner.SpawnEntityFromMessage(engine, m);

            onPlayerCreated?.Invoke(e, m.OwningPlayer);
        }
Example #25
0
        public EntitySpawner PackMonster(Monster tpl)
        {
            EntitySpawner s = new EntitySpawner();

            s.Entity         = tpl;
            s.Interval       = 15;
            s.CountDown      = 2;
            s.MaxCount       = 6;
            s.SpawnCallback  = new Action <MapEntity>(e => s.WorldSpawn.Entities.Add(e));
            s.Position       = tpl.Position;
            s.SpawningVolume = new BoundingBox(new Vector3(-5, 0, -5), new Vector3(5, 0, 5));
            s.Entity.Parent  = s;
            return(s);
        }
Example #26
0
    Entity MakeEntity()
    {
        Vector3 spawnPosition = this.GetSpawnPosition();
        Entity  entity        = EntitySpawner.MakeNewEntity(spawnPosition, this._entityPrefab, this.controller, this._attacher);

        if (this._positionMode == EntitySpawner.PositionMode.Fixed)
        {
            entity.TurnTo(base.transform.forward, 0f);
        }
        else
        {
            entity.TurnTo(UnityEngine.Random.Range(-180f, 180f), 0f);
        }
        return(entity);
    }
Example #27
0
 void Awake()
 {
     Instance = this;
     //FixedEntitiesByChunk = new Dictionary<Vec2i, List<int>>();
     AllEntities               = new Dictionary <int, Entity>();
     LoadedEntities            = new List <LoadedEntity>();
     LoadedChunks              = new List <Vec2i>();
     EntitySpawner             = new EntitySpawner(this);
     NearEntityChunks          = new Dictionary <Vec2i, List <Entity> >();
     LoadedEntityChunks        = new Dictionary <Vec2i, List <Entity> >();
     CurrentWorldCombatEvents  = new List <WorldCombat>();
     ToUnloadEntities          = new List <LoadedEntity>();
     EntitiesByLocation        = new Dictionary <int, Dictionary <Vec2i, List <int> > >();
     PastSubworldEntities      = new List <Entity>();
     UnloadedUpdatableEntities = new HashSet <int>();
 }
Example #28
0
    private void Start()
    {
        I = this;

        Messages         = new GameEventDispatcher();
        SystemController = new SystemController();
        EntityManager    = new EntityController();
        EntitySpawner    = new EntitySpawner();
        MapController.Init();
        UserInputController.Init();
        GameUI.Init();

        flagController = new FlagController();

        EntitySpawner.StartGame();
    }
        public DungeonFactory(DungeonConfig dungeonConfig, EntitySpawner entitySpawner,
                              CharacterId heroId, List <SsarTuple <int, GameObject> > gateAndId,
                              DamageSystem damageSystem, PromiseWorld world, ConfigManager configManager)
        {
            notNullReference.Check(dungeonConfig, "dungeonConfig");
            notNullReference.Check(entitySpawner, "entitySpawner");
            notNullReference.Check(heroId, "heroId");
            notNullReference.Check(gateAndId, "gateAndId");
            notNullReference.Check(damageSystem, "damageSystem");
            notNullReference.Check(configManager, "configManager");

            heroAndMonsterConfig = configManager.GetConfig <HeroAndMonsterConfig>();
            defaultEnvironment   = new DefaultDungeonEnvironment(entitySpawner, gateAndId);
            this.dungeonConfig   = dungeonConfig;

            world.EntityCreationEventHandler += (sender, arg) =>
            {
                Entity entity = arg.Entity;
                if (arg.EntityType != EntityType.Creature)
                {
                    return;
                }

                if (entity.GetComponent <SkillComponent>().CharacterId.Equals(heroId))
                {
                    defaultEnvironment.SetHero(new DefaultDungeonCharacter(entity, damageSystem));
                }
            };

            damageSystem.EntityDeathEventHandler_Late += (sender, args) =>
            {
                CacheTemplateArgsComponent argsComponent = args.Entity.GetComponent <CacheTemplateArgsComponent>();
                SpawnSourceInfo            source        = argsComponent?.TemplateArgs.GetEntry <SpawnSourceInfo>(TemplateArgsName.SpawnSource) ?? new DungeonSystemSpawnSourceInfo();
                EntityRole role = args.Entity.GetComponent <StatsComponent>().BasicStatsFromConfig.ShowRole();
                defaultEnvironment.AddDeadMonster(new EntityMonster(Time.timeSinceLevelLoad,
                                                                    args.Entity.GetComponent <SkillComponent>().CharacterId, args.Entity.UniqueId, source, role));
            };

            entitySpawner.EntitySpawnEventHandler += (sender, args) =>
            {
                if (args.Entity.Group == EntityGroup.GROUP_A)
                {
                    return;
                }
                defaultEnvironment.AddSpawnedMonster(args.UniqueId, args.BasicStats, args.Entity);
            };
        }
Example #30
0
    void Awake()
    {
        // Wipe event listeners in case this isn't the first round of play.
        clearEventListeners();

        Cursor.lockState = CursorLockMode.Locked;
        Cursor.visible   = false;

        BallController.BallSunkEvent    += onBallSunk;
        EntitySpawner.GoalCreatedEvent  += onGoalCreated;
        EntitySpawner.GoalsCreatedEvent += onGoalsCreated;

        waitingToSpawnGoals = true;
        waitDuration        = 5;
        timeWaited          = 0;

        initializeTrophyData();

        spawner = GameObject.FindGameObjectWithTag("EntitySpawner").GetComponent <EntitySpawner>();
    }
Example #31
0
    public static void InitializeWithScene()
    {
        var settingsGO = GameObject.Find("Settings");

        Settings = settingsGO?.GetComponent <Settings>();
        if (!Settings)
        {
            return;
        }

        VectorField.Initialize(Settings);

        EntitySpawner.InitializeWithScene();

        World.Active.GetOrCreateManager <CollisionSystem>().SetupGameObjects();
        World.Active.GetOrCreateManager <InputSystem>().Init();
        World.Active.GetOrCreateManager <WindSystem>().Init();

        NewGame();
    }
Example #32
0
    protected override void Awake()
    {
        base.Awake();

        if (seekTrigger)
        {
            seekTrigger.enterCallback += OnSeekTriggerEnter;
        }

        if (animator)
        {
            animator.takeCompleteCallback += OnAnimatorComplete;
        }

        if (hurtActiveGO)
        {
            hurtActiveGO.SetActive(false);
        }

        mSpawner = GetComponent <EntitySpawner>();
    }
 private WaveManager InitializeEntitySpawner()
 {
     GameObject entitySpawner = SRResources.Core.Base.EntitySpawner.Instantiate();
     entitySpawner.name = "entitySpawner";
     entitySpawner.transform.parent = this.gameObject.transform;
     _entitySpawner = entitySpawner.GetComponent<EntitySpawner>();
     _entitySpawner.InitializeSpawner(this);
     return this;
 }
Example #34
0
 void OnSpawnerSpawned(Entity e, EntitySpawner spawner, string tutorialtag)
 {
     if (EventActions.Count == 0) return;
     var he = new HookEventInfo() {LinkedEntity = e, LinkedSpawner = spawner, tag = tutorialtag, type = TutorialEventType.SpawnerSpawned};
     if (CallActions(he))
     {
         EntitySpawner.OnSpawn -= OnSpawnerSpawned;
     }
 }
Example #35
0
 public ModuleWorker(EntitySpawner spawner, Action<Entity> completedCallback)
 {
     source = spawner;
     SpawnCompletedCallback = completedCallback;
 }