public override void Initialize()
        {
            GameObject pt = ResourceManager.Instance.CurrentScene.GetObject("PlayerTime");

            if (pt == null)
            {
                throw new ArgumentNullException("AreaTransition: PlayerTime object does not exist!");
            }

            cTime = (PlayerTime)pt.GetComponent <PlayerTime>();

            GameObject player = ResourceManager.Instance.CurrentScene.GetObject(1);

            pController = (PlayerController)player.GetComponent <PlayerController>();
            stash       = (HideoutStash)player.GetComponent <HideoutStash>();
            equipment   = pController.Equipment;
            if ((player.GetComponent <PlayerHUD>() as PlayerHUD) != null)
            {
                music = (player.GetComponent <PlayerHUD>() as PlayerHUD).ExplorationCue;
            }

            if (cTime == null || pController == null || stash == null || equipment == null)
            {
                throw new ArgumentNullException("AreaTransition: some required components are inexistant!");
            }

            mBoxes[0]             = new MessageBox(messagePosition, messageDimenstions.X, messageDimenstions.Y);
            mBoxes[0].OptionCount = 3;
            mBoxes[0].Text        = MESSAGE_0;
            mBoxes[0].OptionTexts = new string[] { MESSAGE_0_0, MESSAGE_0_1, MESSAGE_0_2 };
            mBoxes[0].Initialize();

            mBoxes[1]             = new MessageBox(messagePosition, messageDimenstions.X * 0.8f, messageDimenstions.Y);
            mBoxes[1].OptionCount = 2;
            mBoxes[1].Text        = MESSAGE_1;
            mBoxes[1].OptionTexts = new string[] { MESSAGE_1_0, MESSAGE_1_1 };
            mBoxes[1].Initialize();

            mBoxes[2]             = new MessageBox(messagePosition, messageDimenstions.X, messageDimenstions.Y);
            mBoxes[2].OptionCount = 1;
            mBoxes[2].Text        = MESSAGE_2;
            mBoxes[2].OptionTexts = new string[] { MESSAGE_2_0 };
            mBoxes[2].Initialize();

            colliderHelper = new GameObject(MyObject.UniqueID + (uint)MyObject.Name.GetHashCode() + 1, MyObject.Name + "AreaTransitionHelper");
            MyObject.AddChild(colliderHelper);
            colliderHelper.MyTransform          = new Transform(colliderHelper, Vector3.Zero, Vector3.Up, Vector3.Zero, MyObject.MyTransform.Scale * 1.3f);
            colliderHelper.MyCollider           = new SphereCollider(colliderHelper, true);
            colliderHelper.OnTriggerEnterEvent += new GameObject.OnTriggerEnterEventHandler(HelperEnter);
            colliderHelper.OnTriggerExitEvent  += new GameObject.OnTriggerExitEventHandler(HelperExit);

            GameObject playerTimeObj = ResourceManager.Instance.CurrentScene.GetObject(355);

            if (playerTimeObj != null)
            {
                this.playerTime = (PlayerTime)playerTimeObj.GetComponent <PlayerTime>();
            }

            base.Initialize();
        }
Exemple #2
0
        public override void Initialize()
        {
            Material selMat = new Material(MyObject.Name + "FortificationSelectionMat", ResourceManager.Instance.LoadEffect(@"Effects\DefaultEffect"));

            selMat.DiffuseMap    = ResourceManager.Instance.Textures["DefaultDiffuseWhite"];
            selMat.DiffuseColor  = NotBuiltColor;
            selMat.SpecularColor = new Vector3(0.0f, 0.0f, 0.0f);
            selMat.Transparency  = 0.25f;

            model = (CustomModel)MyObject.GetComponent <CustomModel>();

            for (int i = 0; i < model.Mat.Count; ++i)
            {
                selectionMat.Add(selMat);
            }

            currentMat = model.Mat;

            GameObject player = ResourceManager.Instance.CurrentScene.ObjectsDictionary[1];

            hs = (HideoutStash)player.GetComponent <HideoutStash>();

            ps = new ParticleSystem(this.MyObject);
            ps.Textures.Add(ResourceManager.Instance.LoadTexture("Textures/Particles/Particle_metal01"));
            ps.Textures.Add(ResourceManager.Instance.LoadTexture("Textures/Particles/Particle_metal02"));
            ps.Textures.Add(ResourceManager.Instance.LoadTexture("Textures/Particles/Particle_wood01"));
            ps.Textures.Add(ResourceManager.Instance.LoadTexture("Textures/Particles/Particle_wood02"));
            ps.Textures.Add(ResourceManager.Instance.LoadTexture("Textures/Particles/Particle_wood03"));
            ps.ParticleCount         = 10;
            ps.ParticleSize          = new Vector2(0.8f, 1.0f);
            ps.ParticleSizeVariation = new Vector2(0.6f, 0.6f);
            ps.LifespanSec           = 0.8f;
            ps.Wind             = new Vector3(0.0f, 0.0f, -1.0f);
            ps.Offset           = new Vector3(MathHelper.PiOver2);
            ps.Speed            = 10.0f;
            ps.RotationMode     = ParticleSystem.ParticleRotationMode.DIRECTION_Z;
            ps.ParticleRotation = new Vector3(0.0f, 0.0f, MathHelper.PiOver4);
            ps.FadeInTime       = 0.0f;
            ps.FadeOutTime      = 0.05f;
            //ps.PositionOffset = new Vector3(0.0f, -1.0f, 0.0f) * MyObject.MyTransform.Scale;
            ps.BlendMode  = BlendState.AlphaBlend;
            ps.UseGravity = true;
            ps.Mass       = 0.000001f;
            ps.Initialize();

            ps.Stop();

            MyObject.Components.Add(ps);

            HpPerMs    = (float)MaxHealth / ((float)TimeToBuild * 1000.0f);
            PricePerMs = (float)Price / ((float)TimeToBuild * 1000.0f);

            SoundEffect se = TrashSoupGame.Instance.Content.Load <SoundEffect>(@"Audio/Actions/fortificationJebut");

            jebutSound = se.CreateInstance();

            base.Initialize();
        }
        private void LoadToNextLevel()
        {
            stash.CurrentTrash += equipment.JunkCount;
            Safehouse.SafehouseController.Instance.TrashStashed = stash.CurrentTrash + 500;
            SaveManager.Instance.SaveState(stash.CurrentTrash);
            // fade in

            SaveManager.Instance.XmlPath = this.NextScenePath;
            SaveManager.Instance.LoadFileAction();

            stash = (HideoutStash)ResourceManager.Instance.CurrentScene.GetObject(1).GetComponent <HideoutStash>();
            stash.CurrentTrash += SaveManager.Instance.LoadState();

            GUIManager.Instance.FadeClear();
        }
        public override void Initialize()
        {
            MyObject.DrawLast = true;
            int typeNumber = (int)MyType;

            this.interactionTexture = ResourceManager.Instance.LoadTexture(@"Textures/HUD/x_button");

            for (int i = 0; i < PART_IN_TYPE_COUNT; ++i)
            {
                GameObject fortPart = new GameObject(MyObject.UniqueID + (uint)MyObject.Name.GetHashCode() + (uint)i, MyObject.Name + "FortificationPart" + (i).ToString());

                int tN = i + TYPE_COUNT * typeNumber;

                List <Material> mMats = ResourceManager.Instance.LoadBasicMaterialsFromModel(
                    ResourceManager.Instance.LoadModel(PartModels[tN]), ResourceManager.Instance.LoadEffect(@"Effects\NormalEffect"));

                foreach (Material mat in mMats)
                {
                    mat.Glossiness = PartGlosses[tN];
                }

                MyObject.AddChild(fortPart);

                CustomModel mod = new CustomModel(fortPart, new Model[] { ResourceManager.Instance.LoadModel(PartModels[tN]), null, null }, mMats);
                fortPart.Components.Add(mod);
                fortPart.MyTransform = new Transform(fortPart, PartTranslations[tN], Vector3.Up, PartRotations[tN], PartScales[tN]);
                fortPart.MyCollider  = new BoxCollider(fortPart);
                fortPart.Tags.Add("Fortification");

                FortificationPart p = new FortificationPart(fortPart);
                p.MaxHealth   = PartHealths[tN];
                p.Health      = 0;
                p.Price       = PartPrices[tN];
                p.TimeToBuild = PartTimes[tN];
                fortPart.Components.Add(p);

                p.Initialize();

                p.State  = FortificationPart.PartState.PENDING;
                Parts[i] = p;
            }

            if (CurrentID == (int)FortificationState.STATE_EMPTY)
            {
                Parts[0].State = FortificationPart.PartState.NEXT_BUILD;
            }
            else if (CurrentID == (int)FortificationState.STATE_FIRST)
            {
                Parts[0].State  = FortificationPart.PartState.BUILT;
                Parts[0].Health = Parts[0].MaxHealth;
                Parts[1].State  = FortificationPart.PartState.NEXT_BUILD;
            }
            else if (CurrentID == (int)FortificationState.STATE_SECOND)
            {
                Parts[0].State  = FortificationPart.PartState.BUILT;
                Parts[0].Health = Parts[0].MaxHealth;
                Parts[1].State  = FortificationPart.PartState.BUILT;
                Parts[1].Health = Parts[1].MaxHealth;
                Parts[2].State  = FortificationPart.PartState.NEXT_BUILD;
            }
            else if (CurrentID == (int)FortificationState.STATE_THIRD)
            {
                Parts[0].State  = FortificationPart.PartState.BUILT;
                Parts[0].Health = Parts[0].MaxHealth;
                Parts[1].State  = FortificationPart.PartState.BUILT;
                Parts[1].Health = Parts[1].MaxHealth;
                Parts[2].State  = FortificationPart.PartState.BUILT;
                Parts[2].Health = Parts[2].MaxHealth;
            }

            triggerEnemyObj = new GameObject(MyObject.UniqueID + (uint)MyObject.Name.GetHashCode() + (uint)PART_IN_TYPE_COUNT, MyObject.Name + "FortificationTriggerEnemy");

            MyObject.AddChild(triggerEnemyObj);

            triggerEnemyObj.MyTransform          = new Transform(triggerEnemyObj);
            triggerEnemyObj.MyTransform.Position = new Vector3(0.0f, 0.0f, 2.0f);
            triggerEnemyObj.MyTransform.Scale    = 2.0f;
            triggerEnemyObj.MyCollider           = new BoxCollider(triggerEnemyObj, true);

            triggerEnemyObj.OnTriggerEnterEvent += new GameObject.OnTriggerEnterEventHandler(OnTriggerEnterEnemyHandler);
            triggerEnemyObj.OnTriggerExitEvent  += new GameObject.OnTriggerExitEventHandler(OnTriggerExitEnemyHandler);

            ///

            triggerPlayerObj = new GameObject(MyObject.UniqueID + (uint)MyObject.Name.GetHashCode() + (uint)PART_IN_TYPE_COUNT + 1, MyObject.Name + "FortificationTriggerPlayer");

            MyObject.AddChild(triggerPlayerObj);

            triggerPlayerObj.MyTransform          = new Transform(triggerPlayerObj);
            triggerPlayerObj.MyTransform.Position = new Vector3(0.0f, 0.0f, 0.0f);
            triggerPlayerObj.MyTransform.Scale    = 5.0f;
            triggerPlayerObj.MyCollider           = new SphereCollider(triggerPlayerObj, true);

            triggerPlayerObj.OnTriggerEnterEvent += new GameObject.OnTriggerEnterEventHandler(OnTriggerEnterPlayerHandler);
            triggerPlayerObj.OnTriggerExitEvent  += new GameObject.OnTriggerExitEventHandler(OnTriggerExitPlayerHandler);

            for (int i = 0; i < PART_IN_TYPE_COUNT; ++i)
            {
                triggerEnemyObj.MyCollider.IgnoredColliders.Add(Parts[i].MyObject.MyCollider);
                triggerPlayerObj.MyCollider.IgnoredColliders.Add(Parts[i].MyObject.MyCollider);
            }
            triggerEnemyObj.MyCollider.IgnoredColliders.Add(ResourceManager.Instance.CurrentScene.ObjectsDictionary[1].MyCollider);

            GameObject player = ResourceManager.Instance.CurrentScene.ObjectsDictionary[1];

            stashComponent = (HideoutStash)player.GetComponent <HideoutStash>();
            pController    = (PlayerController)player.GetComponent <PlayerController>();

            SoundEffect se = TrashSoupGame.Instance.Content.Load <SoundEffect>(@"Audio/Ambient/building");

            buildSound          = se.CreateInstance();
            buildSound.IsLooped = true;

            base.Initialize();
        }
Exemple #5
0
 public HideoutStash(GameObject go, HideoutStash hs) : base(go, hs)
 {
     CurrentTrashFloat = hs.CurrentTrashFloat;
 }