Beispiel #1
0
    private void Awake()
    {
        Time.timeScale      = timeScale;
        _options            = GameObject.Find("Canvas").transform.Find("Options").gameObject;
        _currVolume         = 0.5f;
        _musicInterpolation = 0;
        try
        {
            _musicManager = GameObject.Find("Music manager").GetComponent <music>();
        }
        catch (NullReferenceException) { }

        isDebug = Application.isEditor;
        _redBar = GameObject.Find("Red_bar");
        _sh     = new StorageHandler();
        ReadColors();
        _pauseMenu         = GameObject.Find("Canvas").GetComponentInChildren <PauseManager>();
        _deathManager      = GameObject.Find("Death manager").GetComponent <DeathManager>();
        _cam               = GameObject.Find("Main Camera").GetComponent <Camera>();
        _pm                = GameObject.Find("PlatformManager").GetComponent <PlatformManager>();
        _rb                = GetComponent <Rigidbody2D>();
        _col               = GetComponent <BoxCollider2D>();
        transform.position = new Vector3(0, GetHeight() / 2, z: transform.position.z);
        _darkener          = GameObject.Find("Canvas").transform.Find("Darkener").GetComponent <Image>();
    }
Beispiel #2
0
 void OnTriggerEnter2D(Collider2D other)                                             //Checks for collision with the player
 {
     if (other.gameObject.tag == "PlayerOneProjectile" || other.gameObject.tag == "PlayerTwoProjectile")
     {
         DeathManager.killProjectile(other.gameObject);
     }
 }
Beispiel #3
0
    public override void ReadBrain()
    {
        if (_agent.Health.IsDead)
        {
            MoveInput = 0;
            DeathManager.ProcessDeath(_agent);
            _agent.gameObject.SetActive(false);
            return;
        }

        if (_eyes.HasTarget == true)
        {
            MoveInput = 0;
            AttackTarget(_eyes.Target);
            return;
        }
        else if (_eyes.LostTarget)
        {
            Attack = false;
            if (!_searching)
            {
                _agent.StartCoroutine(SearchState());
            }
            return;
        }

        Attack = false;
        if (_edgeCheck.EdgeHit && !_turning)
        {
            AtEdgeOfPlatform();
        }
        PatrolBetweenTwoPoints();
    }
Beispiel #4
0
    public void TakeDamage(int damage)
    {
        health -= damage;

        if (characterType == 5)
        {
            if (Random.Range(0, 2) == 0)
            {
                DropPotion(manaPotion, 50f);
            }
            if (Random.Range(0, 2) == 1)
            {
                DropPotion(healthPotion, 30f);
            }
        }

        HealthUI.text        = health.ToString();
        HealthBar.fillAmount = health / maxHealth;

        if (health <= 0)
        {
            if (manaPotion != null && characterType != 0 && characterType != 5)
            {
                int randomInt = Random.Range(0, 2);
                if (randomInt == 0)
                {
                    DropPotion(manaPotion, 101f);
                }
                if (randomInt == 1)
                {
                    DropPotion(healthPotion, 101f);
                }
            }

            if (characterType == 0)
            {
                GetComponent <PlayerController>().OnGameEnd(false);
                DeathManager.Death();
                MusicManager.PlaySound("youdied");
            }

            if (characterType > 0)
            {
                GameObject.FindWithTag("Player").GetComponent <PlayerController>().gaStats.Mobkills++;
                Debug.Log("Mobs killed: " + GameObject.FindWithTag("Player").GetComponent <PlayerController>().gaStats.Mobkills);
                if (characterType == 5)
                {
                    GameObject.FindWithTag("Player").GetComponent <PlayerController>().OnGameEnd(true);
                    WinManager.Win();
                    MusicManager.PlaySound("win");
                }
                else
                {
                    SoundManagerScript.PlaySound("enemydeath1");
                }
            }
            Destroy(gameObject);
        }
    }
Beispiel #5
0
    // Use this for initialization
    void Start()
    {
        death = GameObject.FindGameObjectWithTag("Death").GetComponent <DeathManager>();

        gameOverText = GetComponent <Text>();

        gameOverText.text = gameOverText.text.Replace("<Score>", death.GetEndScore());
        gameOverText.text = gameOverText.text.Replace("<Time>", death.GetEndTime());
    }
 // Start is called before the first frame update
 void Start()
 {
     movingCrosshairLeft  = GameObject.Find("/Canvas/crosshair/crosshairMovingLeft");
     movingCrosshairRight = GameObject.Find("/Canvas/crosshair/crosshairMovingRight");
     blackPieLeft         = GameObject.Find("/Canvas/blackPie/blackPieLeft");
     blackPieRight        = GameObject.Find("/Canvas/blackPie/blackPieRight");
     halo = GameObject.Find("/Canvas/halo");
     dm   = GameObject.Find("FPS").GetComponent <DeathManager>();
     cc   = GameObject.Find("FPS").GetComponent <ColorCheck>();
 }
Beispiel #7
0
 //----------------------------------
 // End of Different Spawn states and ways of doing them
 //----------------------------------
 void Start()
 {
     // sets a random number for the id of the spawner
     SpawnID = Random.Range(1, 500);
     Enemies.Add(EnemyLevels.Easy, EasyEnemy);
     Enemies.Add(EnemyLevels.Boss, BossEnemy);
     Enemies.Add(EnemyLevels.Medium, MediumEnemy);
     Enemies.Add(EnemyLevels.Hard, HardEnemy);
     deathManager = GameObject.Find("Controller").GetComponent <DeathManager>();
 }
Beispiel #8
0
 private void Start()
 {
     controller  = gameObject.GetComponent <CharacterController>();
     dm          = gameObject.GetComponent <DeathManager>();
     cc          = gameObject.GetComponent <ColorCheck>();
     velocity    = new Vector3(0, startSpeed, 0);
     isGrounded  = true;
     wasGrounded = true;
     velocity    = new Vector3(0, initialSpeedY, 0);
 }
Beispiel #9
0
    void Awake()
    {
        if (deathManager == null)
        {
            deathManager = this;
        }
        else
            Destroy(this);

    }
Beispiel #10
0
 private void Awake()
 {
     if (_instance != null && _instance != this)
     {
         Destroy(this.GetComponent <DeathManager>());
     }
     else
     {
         _instance = this;
     }
 }
 public DeathControllerImpl(
     Logger logger,
     SettingsManager settingsManager,
     DeathManager deathManager,
     LoginSessionManager loginSessionManager)
 {
     _logger = logger.Scope("DeathController");
     _loginSessionManager = loginSessionManager;
     _deathManager        = deathManager;
     _settingsManager     = settingsManager;
 }
Beispiel #12
0
 private void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     else
     {
         Debug.LogWarning("Duplicate death manager instance found", this.gameObject);
         Destroy(this);
     }
 }
Beispiel #13
0
    private void Awake()
    {
        if (instance != null && instance != this)
        {
            Destroy(this.gameObject);
            return;
        }

        instance = this;

        DontDestroyOnLoad(this.gameObject);
    }
Beispiel #14
0
 void Awake()
 {
     //HAKEE KOMPONENTIT
     rb2d         = GetComponent <Rigidbody2D>();
     cf2d         = GameObject.Find("Main Camera").GetComponent <CameraFollow2d>();
     dthManager   = GameObject.Find("ScriptBlock").GetComponent <DeathManager>();
     goManager    = GameObject.Find("ScriptBlock").GetComponent <GameOverManager>();
     starManager  = GameObject.Find("ScriptBlock").GetComponent <StarManager>();
     soundManager = GameObject.Find("ScriptBlock").GetComponent <SoundManager>();
     lvlManager   = GameObject.Find("ScriptBlock").GetComponent <LevelManager>();
     motorFire    = this.gameObject.transform.GetChild(0).gameObject;
 }
 public void Start()
 {
     if (Instance == null)
     {
         Instance = this;
     }
     else if (Instance == this)
     {
         Destroy(gameObject);
     }
     DontDestroyOnLoad(gameObject);
 }
 public ServerDispatchControllerImpl(
     PlayerManager playerManager,
     SettingsManager settingsManager,
     DeathManager deathManager,
     DebuffInformation.Factory debuffInformationFactory,
     Logger logger)
 {
     _logger                   = logger.Scope("ServerDispatchController");
     _playerManager            = playerManager;
     _settingsManager          = settingsManager;
     _deathManager             = deathManager;
     _debuffInformationFactory = debuffInformationFactory;
 }
    void Awake()
    {
        instance = this;

        for (int i = 0; i < GameDatabase.instance.enemies.Count(); ++i)
        {
            this.huntedUnitNumList.Add(0);
        }

        ResurectjewelCostTxt.text = string.Format("<size=13><voffset=-0.05em><sprite=0></voffset></size> {0}", RESURECT_JEWEL_COST);
        if (PlayerPrefs.GetInt("IsDeactiveResurectButton") == 1)
        {
            this.ResurectButton.interactable = false;
        }
    }
    DeathManager manager; //reference to the lone death mamanger

    void Start()
    {
        manager = Camera.main.GetComponent <DeathManager>(); //always attached to the camera

        //double check that the collider attached to it is trigger. If it is not, the following method
        //can not run, thus never killing/resetting the player
        if (GetComponent <BoxCollider2D>())
        {
            GetComponent <BoxCollider2D>().isTrigger = true;
        }
        else
        {
            Debug.LogError("An ememy object does not have a collider on it");
        }
    }
    void Start()
    {
        Paladin       paladin       = new Paladin(100);
        DamageManager damageControl = new DamageManager();
        DeathManager  deathManager  = new DeathManager();

        IWeapon sword = new Sword();
        IWeapon axe   = new Axe();

        paladin?.EquipWeapon(sword);
        //paladin?.EquipWeapon(axe);

        damageControl.CalculateDamage(paladin, 100);
        deathManager.ControlDeath(paladin);
    }
Beispiel #20
0
    public void resetProjectile()                                 //在这段代码中没有注释
    {
        GameObject proj;                                          //在这段代码中没有注释

        proj = GameObject.Find("PlayerOneProjectile(Clone)");     //在这段代码中没有注释
        if (proj == null)                                         //在这段代码中没有注释
        {
            proj = GameObject.Find("PlayerTwoProjectile(Clone)"); //在这段代码中没有注释
        }

        if (proj != null)                      //在这段代码中没有注释
        {
            DeathManager.killProjectile(proj); //在这段代码中没有注释
        }
    }
Beispiel #21
0
            //-----------------------------------------------------------------------------
            // Game::UnLoadContent()
            //       unload content (resources loaded above)
            //       unload all content that was loaded before the Engine Loop started
            //-----------------------------------------------------------------------------
            public override void UnLoadContent()
            {
                TextureManager.Destroy();
                ImageManager.Destroy();

                GameSpriteManager.Destroy();
                BoxSpriteManager.Destroy();

                SpriteBatchManager.Destroy();

                ProxySpriteManager.Destroy();

                TimerEventManager.Destroy();
                DeathManager.Destroy();
            }
Beispiel #22
0
    // Use this for initialization
    void Start()
    {
        //Get Audiomanager
        try
        {
            audioManager = FindObjectOfType <AudioManager>();
        }

        catch
        {
            Debug.LogWarning("Could not find audio Manager");
        }

        audioPlayed = false;

        //Init pickups
        NumberFoundClams = 0;

        clamUiImages.Add(GameObject.Find("ClamUI1").GetComponent <Image>());
        clamUiImages.Add(GameObject.Find("ClamUI2").GetComponent <Image>());
        clamUiImages.Add(GameObject.Find("ClamUI3").GetComponent <Image>());

        //Get parent object
        rootObject = gameObject.transform.parent.gameObject;

        //Get components -> should have null checks. RequireComponent could be good.
        deathManager = gameObject.GetComponent <DeathManager>();
        hidePlayer   = gameObject.GetComponent <HidePlayer>();
        followCamera = rootObject.GetComponentInChildren <Cinemachine.CinemachineVirtualCamera>();
        timer        = gameObject.GetComponent <Timer>();

        armRadius = gameObject.GetComponentInChildren <SpriteRenderer>();

        //Find the SceneData object in the scene and store it's data script.
        //There may well be a nicer way of doing this.
        try
        {
            sceneData = GameObject.Find("SceneData").GetComponent <SceneData>();
        }

        catch (System.NullReferenceException)
        {
            Debug.LogError("No SceneData component in scene. Add a SceneData prefab! \nAlternatively you may have renamed it to something other than SceneData.");
        }

        //Get the checkpoint manager from the parent transform. Could put the checkpoint manager just on the octo itself possibly.
        checkpointManager = gameObject.GetComponentInParent <CheckpointManager>();
    }
Beispiel #23
0
 void Start()
 {
     if (IsInCorrectScene())
     {
         gameMaster         = GameObject.FindGameObjectWithTag("GameMaster");
         sphereShop         = GameObject.FindGameObjectWithTag("Icosphere").GetComponent <SphereShop>();
         mouseCursorManager = gameMaster.GetComponent <MouseCursorManager>();
         deathManager       = gameMaster.GetComponent <DeathManager>();
         buildManager       = gameMaster.GetComponent <BuildManager>();
         towerManager       = gameMaster.GetComponent <TowerManager>();
         shopScript         = gameMaster.GetComponent <InstancesManager>().GetShopGObj().GetComponent <Shop>();
         soulsCounter       = SoulsCounter.instance;
         scoreCounter       = ScoreCounter.instance;
         towerToBuild       = null;
         isAlreadBuilt      = false;
     }
 }
Beispiel #24
0
 static bool DefaultReleaseFallback(GameObject obj)
 {
     try
     {
         DeathManager deathManager = obj.GetComponent <DeathManager>();
         if (deathManager != null)
         {
             deathManager.simpleDeath();
         }
         Object.Destroy(obj);
         return(true);
     }
     catch
     {
         return(false);
     }
 }
    private void Start()
    {
        highScores   = GameObject.Find("GameMaster").GetComponent <HighScores> ();
        deathManager = GameObject.Find("GameMaster").GetComponent <DeathManager> ();
        fading       = GameObject.Find("GameMaster").GetComponent <Fading> ();

        SetleaderBoadCanvas(true);
        SetleaderBoadCanceledCanvas(true);
        nameList   = GameObject.Find("NameList");
        waveList   = GameObject.Find("WaveList");
        scoreList  = GameObject.Find("ScoreList");
        nameListC  = GameObject.Find("NameListC");
        waveListC  = GameObject.Find("WaveListC");
        scoreListC = GameObject.Find("ScoreListC");
        SetleaderBoadCanvas(false);
        SetleaderBoadCanceledCanvas(false);
    }
    // Start is called before the first frame update
    void Start()
    {
        if (DeathPrefabs.Length != 6)
        {
            Debug.LogError("Death prefabs error");
            gameObject.SetActive(false);
        }

        if (Instance != null)
        {
            Destroy(gameObject);
            return;
        }

        Instance = this;
        DontDestroyOnLoad(gameObject);
        SceneManager.activeSceneChanged += SceneManager_activeSceneChanged;
    }
Beispiel #27
0
    public Level() : base()
    {
        levelMusic = new Music();
        levelMusic.musicSoundChannel        = levelMusic.gameTrack.Play();
        levelMusic.musicSoundChannel.Volume = Music.musicVolume;

        difficulty = new Difficulty(); //Don't ask please.

        //initialise variables
        _scrollSpeed = Difficulty.GetScrollSpeed();
        _tileSize    = Difficulty.GetTileSize();
        _tileCount   = 0;

        //Timer initialization
        _lastUpdatedVictimTime = 0;
        _lastUpdatedEnemyTime  = 0;
        _lastUpdatedCarsTime   = 0;
        _lastUpdatedBikesTime  = 0;

        //Depth
        _floorLayer      = new LevelLayer();
        _groundPoopLayer = new LevelLayer();
        _victimLayer     = new LevelLayer();
        _poopLayer       = new LevelLayer();
        _powerUpLayer    = new LevelLayer();
        _flightLayer     = new LevelLayer();
        _hudLayer        = new LevelLayer();
        AddChild(_floorLayer);
        AddChild(_groundPoopLayer);
        AddChild(_victimLayer);
        AddChild(_poopLayer);
        AddChild(_powerUpLayer);
        AddChild(_flightLayer);
        AddChild(_hudLayer);

        deathManager = new DeathManager(this);
        AddChild(deathManager);

        CreatePlayer();
        CreateRoad();
        CreateHUD();
    }
Beispiel #28
0
    private IEnumerator ActuallyKill()
    {
        if (!dead)
        {
            dead = true;
            DeathManager d = FindObjectOfType <DeathManager>();
            if (d)
            {
                d.FadeIn(2);
            }
            yield return(new WaitForSeconds(4));

            SceneLoader loader = FindObjectOfType <SceneLoader>();
            if (loader)
            {
                loader.Load("menu");
            }
        }
        yield break;
    }
Beispiel #29
0
        public override void Execute()
        {
            dm = GameObject.FindObjectOfType <DeathManager>();
            var player = model.player;

            if (player.health.IsAlive)
            {
                player.health.Die();
                model.virtualCamera.m_Follow = null;
                model.virtualCamera.m_LookAt = null;
                // player.collider.enabled = false;
                player.controlEnabled = false;

                if (player.audioSource && player.ouchAudio)
                {
                    player.audioSource.PlayOneShot(player.ouchAudio);
                }
                player.animator.SetTrigger("hurt");
                player.animator.SetBool("dead", true);
                Simulation.Schedule <PlayerSpawn>(2);
                dm.IncreaseDeaths();
            }
        }
 /// <summary>
 /// Sets the death manager
 /// </summary>
 /// <param name="deathManager">Sets the death manager</param>
 public void setDeathManager(DeathManager deathManager)
 {
     this.deathManager = deathManager;
 }
Beispiel #31
0
 //----------------------------------
 // End of Different Spawn states and ways of doing them
 //----------------------------------
 void Start()
 {
     // sets a random number for the id of the spawner
     SpawnID = Random.Range(1, 500);
     Enemies.Add(EnemyLevels.Easy, EasyEnemy);
     Enemies.Add(EnemyLevels.Boss, BossEnemy);
     Enemies.Add(EnemyLevels.Medium, MediumEnemy);
     Enemies.Add(EnemyLevels.Hard, HardEnemy);
     deathManager = GameObject.Find("Controller").GetComponent<DeathManager>();
 }
Beispiel #32
0
        /**
         * If the component requires other custom components then do it here.
         * Read the comment on Components.MantaSeializationFixer if you wish to understand why this horrible system exists.
         */
        public static void SetUpManta(GameObject submarine)
        {
            MantaSubmarine     mantaSubmarine     = submarine.GetComponent <MantaSubmarine>();
            Transform          applyForceLocation = submarine.FindChild("PointsOfInterest").FindChild("ForceAppliedLocation").transform;
            MovementController movementController = submarine.GetOrAddComponent <MovementController>();

            movementController.ApplyForceLocation = applyForceLocation;

            GameObject doorLeft = submarine.FindChild("PointsOfInterest").FindChild("PlayerEntranceLeftFlap");

            doorLeft.GetComponentInChildren <HingeJoint>().connectedBody = submarine.GetComponent <Rigidbody>();
            HingeJointDoor hingeDoorLeft = doorLeft.GetOrAddComponent <HingeJointDoor>();

            hingeDoorLeft.OverwriteTargetVelocity = true;
            hingeDoorLeft.TargetVelocity          = 150f;
            hingeDoorLeft.TriggerToEverything     = false;
            hingeDoorLeft.TriggerToPlayer         = true;
            hingeDoorLeft.TriggerToVehicles       = false;
            hingeDoorLeft.OpenSound  = CyclopsDefaultAssets.PLAYER_HATCH_OPEN;
            hingeDoorLeft.CloseSound = CyclopsDefaultAssets.PLAYER_HATCH_CLOSE;

            GameObject doorRight = submarine.FindChild("PointsOfInterest").FindChild("PlayerEntranceRightFlap");

            doorRight.GetComponentInChildren <HingeJoint>().connectedBody = submarine.GetComponent <Rigidbody>();
            HingeJointDoor hingeDoorRight = doorRight.GetOrAddComponent <HingeJointDoor>();

            hingeDoorRight.OverwriteTargetVelocity = true;
            hingeDoorRight.TargetVelocity          = 150f;
            hingeDoorRight.TriggerToEverything     = false;
            hingeDoorRight.TriggerToPlayer         = true;
            hingeDoorRight.TriggerToVehicles       = false;
            hingeDoorRight.OpenSound  = CyclopsDefaultAssets.PLAYER_HATCH_OPEN;
            hingeDoorRight.CloseSound = CyclopsDefaultAssets.PLAYER_HATCH_CLOSE;

            GameObject vehicleDoorLeft = submarine.FindChild("PointsOfInterest").FindChild("VehicleEntranceLeftFlap");

            vehicleDoorLeft.GetComponentInChildren <HingeJoint>().connectedBody = submarine.GetComponent <Rigidbody>();
            HingeJointDoor hingeVehicleDoorLeft = vehicleDoorLeft.GetOrAddComponent <HingeJointDoor>();

            hingeVehicleDoorLeft.OverwriteTargetVelocity = true;
            hingeVehicleDoorLeft.TargetVelocity          = 150f;
            hingeVehicleDoorLeft.TriggerToEverything     = false;
            hingeVehicleDoorLeft.TriggerToPlayer         = false;
            hingeVehicleDoorLeft.TriggerToVehicles       = true;
            hingeVehicleDoorLeft.OpenSound  = CyclopsDefaultAssets.DOCKING_DOORS_OPEN;
            hingeVehicleDoorLeft.CloseSound = CyclopsDefaultAssets.DOCKING_DOORS_CLOSE;

            GameObject vehicleDoorRight = submarine.FindChild("PointsOfInterest").FindChild("VehicleEntranceRightFlap");

            vehicleDoorRight.GetComponentInChildren <HingeJoint>().connectedBody = submarine.GetComponent <Rigidbody>();
            HingeJointDoor hingeVehicleDoorRight = vehicleDoorRight.GetOrAddComponent <HingeJointDoor>();

            hingeVehicleDoorRight.OverwriteTargetVelocity = true;
            hingeVehicleDoorRight.TargetVelocity          = 150f;
            hingeVehicleDoorRight.TriggerToEverything     = false;
            hingeVehicleDoorRight.TriggerToPlayer         = false;
            hingeVehicleDoorRight.TriggerToVehicles       = true;
            hingeVehicleDoorRight.OpenSound  = CyclopsDefaultAssets.DOCKING_DOORS_OPEN;
            hingeVehicleDoorRight.CloseSound = CyclopsDefaultAssets.DOCKING_DOORS_CLOSE;

            GameObject    entrancePosition      = submarine.FindChild("PointsOfInterest").FindChild("EntranceTeleportSpot");
            GameObject    entranceHatch         = submarine.FindChild("PointsOfInterest").FindChild("PlayerEntrance").FindChild("Base");
            EntranceHatch entranceHatchTeleport = entranceHatch.GetOrAddComponent <EntranceHatch>();

            entranceHatchTeleport.HoverText         = "Board Manta";
            entranceHatchTeleport.HoverHandReticle  = HandReticle.IconType.Hand;
            entranceHatchTeleport.TeleportTarget    = entrancePosition;
            entranceHatchTeleport.Submarine         = mantaSubmarine;
            entranceHatchTeleport.EnteringSubmarine = true;

            GameObject    leavePosition      = submarine.FindChild("PointsOfInterest").FindChild("LeaveTeleportSpot");
            GameObject    leaveHatch         = submarine.FindChild("PointsOfInterest").FindChild("PlayerEntrance").FindChild("Top");
            EntranceHatch leaveHatchTeleport = leaveHatch.GetOrAddComponent <EntranceHatch>();

            leaveHatchTeleport.HoverText         = "Disembark Manta";
            leaveHatchTeleport.HoverHandReticle  = HandReticle.IconType.Hand;
            leaveHatchTeleport.TeleportTarget    = leavePosition;
            leaveHatchTeleport.Submarine         = mantaSubmarine;
            leaveHatchTeleport.EnteringSubmarine = false;

            GameObject      steeringConsolePOI             = submarine.FindChild("PointsOfInterest").FindChild("SteeringConsole");
            GameObject      steeringConsoleLeftHandTarget  = submarine.FindChild("PointsOfInterest").FindChild("SteeringConsole").FindChild("LeftIKTarget");
            GameObject      steeringConsoleRightHandTarget = submarine.FindChild("PointsOfInterest").FindChild("SteeringConsole").FindChild("RightIKTarget");
            GameObject      playerParentWhilePiloting      = submarine.FindChild("PointsOfInterest").FindChild("SteeringConsole").FindChild("PlayerLockedWhileSteeringPosition");
            SteeringConsole steeringConsole = steeringConsolePOI.GetOrAddComponent <SteeringConsole>();

            steeringConsole.MovementController    = submarine.GetComponent <MovementController>();
            steeringConsole.ParentWhilePilotingGO = playerParentWhilePiloting;
            steeringConsole.LeftHandIKTarget      = steeringConsoleLeftHandTarget;
            steeringConsole.RightHandIKTarget     = steeringConsoleRightHandTarget;
            steeringConsole.Submarine             = mantaSubmarine;

            CyclopsCollisionSounds collisionSounds = submarine.GetOrAddComponent <CyclopsCollisionSounds>();

            MovementData normalSpeedMovementData = new MovementData
            {
                ForwardAccelerationSpeed   = 5f,
                BackwardsAccelerationSpeed = 3f,
                AscendDescendSpeed         = 3f,
                RotationSpeed = 0.3f,
                StrafeSpeed   = 2f
            };

            EngineManager engineManager = submarine.GetOrAddComponent <EngineManager>();

            engineManager.SetMovementDataForEngineState(EngineState.SLOW, normalSpeedMovementData);
            engineManager.SetMovementDataForEngineState(EngineState.NORMAL, normalSpeedMovementData);
            engineManager.SetMovementDataForEngineState(EngineState.FAST, normalSpeedMovementData);
            engineManager.SetMovementDataForEngineState(EngineState.SPECIAL, normalSpeedMovementData);

            CyclopsStartupPowerDownSequence   cyclopsStartupPowerDownSequence   = submarine.GetOrAddComponent <CyclopsStartupPowerDownSequence>();
            CyclopsEngineStateChangedCallouts cyclopsEngineStateChangedCallouts = submarine.GetOrAddComponent <CyclopsEngineStateChangedCallouts>();

            movementController.EngineManager = engineManager;
            CyclopsWelcomeCallout cyclopsWelcomeCallout = submarine.GetOrAddComponent <CyclopsWelcomeCallout>();
            CyclopsEngineSound    cyclopsEngineSound    = submarine.GetOrAddComponent <CyclopsEngineSound>();

            cyclopsEngineSound.RampUpSpeed   = 0.2f;
            cyclopsEngineSound.RampDownSpeed = 0.2f;
            movementController.EngineSound   = cyclopsEngineSound;

            OxygenReplenishment oxygenReplenishment = submarine.GetOrAddComponent <OxygenReplenishment>();

            oxygenReplenishment.OxygenPerSecond  = 15f;
            oxygenReplenishment.OxygenEnergyCost = 0.1f;

            LiveMixin liveMixin = submarine.GetOrAddComponent <LiveMixin>();

            liveMixin.data           = CyclopsLiveMixinData.Get(); // TO:DO Create a proper health system for the manta.
            liveMixin.data.knifeable = true;                       // TO:DO remove just here for testing purposes.
            liveMixin.data.maxHealth = 500;

            GameObject externalLights = submarine.FindChild("Lights").FindChild("Exterior");
            GameObject internalLights = submarine.FindChild("Lights").FindChild("Interior");

            LightsManager lightsManager      = submarine.GetOrAddComponent <LightsManager>();
            List <Light>  internalLightsList = new List <Light>();
            List <Light>  externalLightsList = new List <Light>();

            foreach (Light light in externalLights.GetComponentsInChildren <Light>())
            {
                externalLightsList.Add(light);
            }
            foreach (Light light in internalLights.GetComponentsInChildren <Light>())
            {
                internalLightsList.Add(light);
            }
            lightsManager.ExternalLights              = externalLightsList;
            lightsManager.InternalLights              = internalLightsList;
            lightsManager.ExternalLightsOnIntensity   = 1.5f;
            lightsManager.ExternalLightsOffIntensity  = 0f;
            lightsManager.InternalLightsOnIntensity   = 1.5f;
            lightsManager.InternalLightsOffIntensity  = 0f;
            lightsManager.EnableInternalLightsOnStart = true;
            lightsManager.EnableExternalLightsOnStart = true;

            CyclopsUnderAttackEmergencyLighting emergencyLighting = submarine.GetOrAddComponent <CyclopsUnderAttackEmergencyLighting>();

            emergencyLighting.LightsAffected = internalLightsList;

            submarine.GetOrAddComponent <CyclopsUnderAttackCallout>();

            ExternalDamageManager externalDamageManager = submarine.GetOrAddComponent <ExternalDamageManager>();

            externalDamageManager.DamagePoints       = submarine.FindChild("PointsOfInterest").FindChild("DamagePoints").transform;
            externalDamageManager.SubmarineLiveMixin = liveMixin;
            externalDamageManager.LiveMixinDataForExternalDamagePoints = CyclopsExternalDamagePointLiveMixinData.Get();
            externalDamageManager.DamagePointParticleEffects           = new List <GameObject>()
            {
                CyclopsDefaultAssets.EXTERNAL_DAMAGE_POINT_PARTICLES,
            };
            externalDamageManager.DamagePointGameObjects = new List <GameObject>()
            {
                CyclopsDefaultAssets.EXTERNAL_DAMAGE_POINT,
            };

            InternalFireManager internalFireManager = submarine.GetOrAddComponent <InternalFireManager>();

            internalFireManager.SubmarineLiveMixin = liveMixin;
            internalFireManager.FirePoints         = submarine.FindChild("PointsOfInterest").FindChild("FirePoints").transform;
            internalFireManager.FirePrefabs        = new List <GameObject>()
            {
                CyclopsDefaultAssets.CYCLOPS_FIRE,
            };
            internalFireManager.DamageDonePerFirePerSecond = 5f;
            internalFireManager.Submarine = mantaSubmarine;
            internalFireManager.ChancePerDamageTakenToSpawnFire = 5;

            AutoRegenConditional autoRegen = submarine.GetOrAddComponent <AutoRegenConditional>();

            autoRegen.InternalFireManager   = internalFireManager;
            autoRegen.ExternalDamageManager = externalDamageManager;
            autoRegen.LiveMixin             = liveMixin;
            autoRegen.RegenPerSecond        = 2f;

            InternalLeakManager internalLeakManage = submarine.GetOrAddComponent <InternalLeakManager>();

            internalLeakManage.LeakPrefabs = new List <GameObject>()
            {
                CyclopsDefaultAssets.WATER_LEAK
            };

            DeathManager deathManager = submarine.GetOrAddComponent <DeathManager>();

            deathManager.DeathPreparationTime = 22f;

            BasicDeath basicDeath = submarine.GetOrAddComponent <BasicDeath>();

            basicDeath.TimeTillDeletionOfSub = 60f;
            basicDeath.FallSpeed             = 2f;

            CyclopsDeathExplosion cyclopsDeathExplosion = submarine.GetOrAddComponent <CyclopsDeathExplosion>();

            cyclopsDeathExplosion.TimeToExplosionAfterDeath = 18f;
            cyclopsDeathExplosion.FMODAsset = CyclopsDefaultAssets.CYCLOPS_EXPLOSION_FMOD;

            CyclopsAbandonShip cyclopsAbandonShip = submarine.GetOrAddComponent <CyclopsAbandonShip>();

            cyclopsAbandonShip.TimeToCalloutAfterDeath = 0f;
            cyclopsAbandonShip.FMODAsset = CyclopsDefaultAssets.AI_ABANDON;

            DestabiliseOnSubDeath      destabiliseOnSubDeath      = submarine.GetOrAddComponent <DestabiliseOnSubDeath>();
            KillPlayerInsideOnSubDeath killPlayerInsideOnSubDeath = submarine.GetOrAddComponent <KillPlayerInsideOnSubDeath>();

            // Temp screens
            GameObject helmMantaOSScreen            = submarine.FindChild("PointsOfInterest").FindChild("UpgradesAndBatteries").FindChild("HelmScreen").FindChild("Canvas");
            GameObject rearMantaOSScreen            = submarine.FindChild("PointsOfInterest").FindChild("UpgradesAndBatteries").FindChild("UpgradeScreen").FindChild("Canvas");
            GameObject steeringConsoleMantaOSScreen = submarine.FindChild("PointsOfInterest").FindChild("SteeringConsole").FindChild("Canvas");

            Object.Instantiate(MantaAssetLoader.MANTA_OS_MAIN_LAYOUT_PAGE).transform.SetParent(helmMantaOSScreen.transform, false);
            Object.Instantiate(MantaAssetLoader.MANTAOS_OFFLINE_PAGE).transform.SetParent(rearMantaOSScreen.transform, false);
            Object.Instantiate(MantaAssetLoader.MANTAOS_OFFLINE_PAGE).transform.SetParent(steeringConsoleMantaOSScreen.transform, false);

            SMLHelper.V2.Handlers.TechTypeHandler.TryGetModdedTechType(UNIQUE_ID, out TechType mantaTechType);
            PingType     mantaPingType = CustomBeaconManager.RegisterNewPingType(mantaTechType, NAME, MantaAssetLoader.MANTA_PING_ICON);
            PingInstance pingInstance  = CustomBeaconManager.AddNewBeacon(submarine, mantaPingType, "HMS Unknown Manta");
        }
 /// <summary>
 /// Sets the entire game
 /// </summary>
 /// <param name="finished">True if the game was completed; otherwise, false</param>
 public void resetGame(bool finished)
 {
     foreach (Level l in game.getLevels()) {
         deathManager.resetLevel(l, 3);
     }
     deathManager.resetPlayer(3);
     level.setActive(false);
     game.setLevel(0);
     level = game.getLevel(0);
     prevLevel = level;
     game.setLevel(level);
     deathManager = new DeathManager(this);
     setDeathManager(deathManager);
     collisionManager.setLevel(level);
     level.setActive(true);
     player.setLocation(level.getPlayerOrigin());
     playerManager.getKeyBox().update(this);
     Numberpad num = (Numberpad) level.getScreen("Numberpad");
     num.setSolved(false);
     if (finished) {
         TitleScreen title = (TitleScreen) level.getScreen("Title screen");
         title.setActive(true);
     } else {
         dropText = "Game over!";
     }
     if (selectedObject != null) {
         selectedObject.setSelected(false);
     }
     selectedObject = null;
     gameState = GameState.Normal;
     moving = false;
     menuShown = false;
     stagnant = false;
     ticks = 0;
 }
Beispiel #34
0
 public void Awake()
 {
     instance = this;
     deadEntities = new List<Entity>();
     toDestroy = new List<Entity>();
 }
Beispiel #35
0
 public void Awake()
 {
     instance = this;
     toDestroy = new Queue<DeathData>();
 }
 private void updateNormal(GameTime time)
 {
     if (!(collisionManager.getObjectCollision(player, true) is PlayerLimitationField)) {
         playerManager.setManaLimit(true);
         playerManager.setHealthLimit(true);
     }
     if (playerManager.getHealthCooldown() == 35 && playerManager.getHealthLimit() && playerManager.getManaLimit()) {
         playerManager.regenerateHealth();
         playerManager.regenerateMana();
     }
     foreach (Npc n in level.getNpcs()) {
         NpcDefinition def = n.getDefinition();
         if (def.getHints().Length > 0 && def.isShowing()) {
             def.update(false);
         }
     }
     GameObject gCollision = collisionManager.getObjectCollision(player, true);
     if (gCollision != null && gCollision is Token) {
         Token t = (Token) gCollision;
         level.takeCollectible(t);
         playerManager.incrementExperience(t.getExp());
         playerManager.levelMana(t.getManaIncrementationValue());
         PauseMenu pause = (PauseMenu) level.getScreen("Pause");
         pause.setExperience(pause.getExperience() + t.getExp());
         dropText = "+ " + t.getExp() + " EXP";
         t.playEffect();
     } else if (gCollision != null && gCollision is Key) {
         Key k = (Key) gCollision;
         level.takeCollectible(k);
         k.setUnlocked(true);
         level.unlockDoors();
         k.playEffect();
     } else if (gCollision != null && gCollision is Door) {
         Door d = (Door) gCollision;
         if (d.isUnlocked()) {
             int next = (game.getLevelIndex()) + (d.continues() ? 1 : -1);
             if (next == 7) {
                 gameState = GameState.Outro;
                 finished = true;
                 return;
             }
             Song current = level.getSong();
             level.setActive(false);
             game.setLevel(next);
             prevLevel = level;
             level = game.getLevel(next);
             PauseMenu pause = (PauseMenu) level.getScreen("Pause");
             pause.setLevel(next);
             if (current != level.getSong()) {
                 MediaPlayer.Stop();
                 MediaPlayer.Play(level.getSong());
                 if (d.continues()) {
                     game.getLevel(next - 2).setLooped(false);
                     prevLevel.setLooped(false);
                 } else {
                     level.setLooped(false);
                     prevLevel.setLooped(false);
                 }
                 level.setLooped(true);
             }
             game.setLevel(level);
             deathManager = new DeathManager(this);
             setDeathManager(deathManager);
             collisionManager.getLevel().setActive(false);
             level.setInputManager(this);
             collisionManager.setLevel(level);
             level.setActive(true);
             if (d.continues()) {
                 player.setLocation(level.getPlayerOrigin());
             } else {
                 player.setLocation(level.getPlayerReentryPoint());
             }
             playerManager.getKeyBox().update(this);
         } else if (game.getLevelIndex() == 0) {
             Numberpad num = (Numberpad) level.getScreen("Numberpad");
             if (!num.isSolved()) {
                 if (gameState == GameState.Normal) {
                     if (showPuzzle) {
                         gameState = GameState.Puzzle;
                         level.setActive(false);
                     }
                 }
             } else {
                 d.setUnlocked(true);
             }
         }
     } else if (gCollision != null && gCollision is Pit) {
         Pit p = (Pit) gCollision;
         p.update(this);
         if (p is Laser) {
             Laser laser = (Laser) p;
             if (laser.isActivated()) {
                 p.playEffect();
             }
         } else {
             p.playEffect();
         }
         if (p is PlayerLimitationField) {
             PlayerLimitationField plf = (PlayerLimitationField) p;
             plf.update(this);
             plf.playEffect();
         }
     }
     if (lastKeyState.IsKeyDown(Keys.M) && currentKeyState.IsKeyUp(Keys.M)) {
         if (gameState == GameState.Normal) {
             gameState = GameState.PauseMenu;
             level.setActive(false);
         } else {
             gameState = GameState.Normal;
             level.setActive(true);
         }
     } else if (lastKeyState.IsKeyDown(Keys.E) && currentKeyState.IsKeyUp(Keys.E)) {
         if (mindRead.validate()) {
             playerManager.depleteMana(mindRead.getManaCost());
             foreach (Npc n in level.getNpcs()) {
                 if (player.getDistance(n) <= 200) {
                     NpcDefinition def = n.getDefinition();
                     if (def.getHints().Length > 0) {
                         def.update(true);
                     }
                 }
             }
         }
     }
     if (playerManager.getManaLimit()) {
         mindRead.activate(level);
         SlowTime slowmo = (SlowTime) playerManager.getPowers()[0];
         if (lastKeyState.IsKeyDown(Keys.A) && currentKeyState.IsKeyUp(Keys.A)) {
             if (slowmo.validate()) {
                 playerManager.depleteMana(slowmo.getManaCost());
             }
         }
         slowmo.activate(level);
         Dash dash = (Dash) playerManager.getPowers()[1];
         if (lastKeyState.IsKeyDown(Keys.W) && currentKeyState.IsKeyUp(Keys.W)) {
             if (dash.validate()) {
                 playerManager.depleteMana(dash.getManaCost());
             }
         }
         dash.activate(level);
         Confuse confuse = (Confuse) playerManager.getPowers()[2];
         if (lastKeyState.IsKeyDown(Keys.S) && currentKeyState.IsKeyUp(Keys.S)) {
             if (confuse.validate()) {
                 playerManager.depleteMana(confuse.getManaCost());
             }
         }
         confuse.activate(level);
     }
     Entity eCollision = collisionManager.getEntityCollision(player);
     if (currentKeyState.IsKeyDown(Keys.Up)) {
         showPuzzle = true;
         player.setDirection(Direction.North);
         player.updateMovement();
         player.setDestination(new Vector2(player.getLocation().X, player.getLocation().Y - velocity));
         if (player.getDestination().Y >= 0 && collisionManager.isValid(player, false)) {
             player.deriveY(-velocity);
         } else {
             if (!(collisionManager.getObjectCollision(player, false) is Door)) {
                 player.setDestination(player.getLocation());
             }
             if (eCollision != null) {
                 eCollision.setDestination(eCollision.getLocation());
             }
         }
     } else if (lastKeyState.IsKeyDown(Keys.Up) && currentKeyState.IsKeyUp(Keys.Up)) {
         stagnant = true;
     } else if (currentKeyState.IsKeyDown(Keys.Down)) {
         showPuzzle = true;
         player.setDirection(Direction.South);
         player.updateMovement();
         player.setDestination(new Vector2(player.getLocation().X, player.getLocation().Y + velocity));
         if (player.getDestination().Y <= height - player.getTexture().Height && collisionManager.isValid(player, false)) {
             player.deriveY(velocity);
         } else {
             if (!(collisionManager.getObjectCollision(player, false) is Door)) {
                 player.setDestination(player.getLocation());
             }
             if (eCollision != null) {
                 eCollision.setDestination(eCollision.getLocation());
             }
         }
     } else if (lastKeyState.IsKeyDown(Keys.Down) && currentKeyState.IsKeyUp(Keys.Down)) {
         stagnant = true;
     } else if (currentKeyState.IsKeyDown(Keys.Left)) {
         showPuzzle = true;
         player.setDirection(Direction.West);
         player.updateMovement();
         player.setDestination(new Vector2(player.getLocation().X - velocity, player.getLocation().Y));
         if (player.getDestination().X >= 0 && collisionManager.isValid(player, false)) {
             player.deriveX(-velocity);
         } else {
             if (!(collisionManager.getObjectCollision(player, false) is Door)) {
                 player.setDestination(player.getLocation());
             }
             if (eCollision != null) {
                 eCollision.setDestination(eCollision.getLocation());
             }
         }
     } else if (lastKeyState.IsKeyDown(Keys.Left) && currentKeyState.IsKeyUp(Keys.Left)) {
         stagnant = true;
     } else if (currentKeyState.IsKeyDown(Keys.Right)) {
         showPuzzle = true;
         player.setDirection(Direction.East);
         player.updateMovement();
         player.setDestination(new Vector2(player.getLocation().X + velocity, player.getLocation().Y));
         if (player.getDestination().X <= width - 64 && collisionManager.isValid(player, false)) {
             player.deriveX(velocity);
         } else {
             if (!(collisionManager.getObjectCollision(player, false) is Door)) {
                 player.setDestination(player.getLocation());
             }
             if (eCollision != null) {
                 eCollision.setDestination(eCollision.getLocation());
             }
         }
     } else if (lastKeyState.IsKeyDown(Keys.Right) && currentKeyState.IsKeyUp(Keys.Right)) {
         stagnant = true;
     } else {
         player.setDestination(player.getLocation());
     }
     if (currentKeyState.IsKeyDown(Keys.Space) && playerManager.getManaLimit()) {
         double ms = time.TotalGameTime.TotalMilliseconds;
         if ((player.getLastFired() == -1 || ms - player.getLastFired() >= player.getProjectile().getCooldown()) && playerManager.getMana() >= 5) {
             level.addProjectile(player.createProjectile(ms));
             playerManager.depleteMana(5);
         }
     }
     if (lastKeyState.IsKeyDown(Keys.Q) && currentKeyState.IsKeyUp(Keys.Q)) {
         gameState = GameState.TelekinesisSelect;
         level.setMode(1);
     }
 }