Beispiel #1
0
        public override void Initialize()
        {
            this.interactionTexture = ResourceManager.Instance.LoadTexture(@"Textures/HUD/x_button");
            this.noteTexture        = ResourceManager.Instance.LoadTexture(@"Textures/Storyline/note");

            myPoint = new LightPoint(110, "LightPoint1", Color.Blue.ToVector3(), Color.Blue.ToVector3(), 6.0f, false);
            MyObject.AddChild(myPoint);
            myPoint.MyTransform            = new Transform(myPoint, new Vector3(0.0f, 0.25f, 0.0f), new Vector3(0.0f, 1.0f, 0.0f), new Vector3(0.0f, 0.0f, 0.0f), 1.0f);
            myPoint.MyCollider             = new SphereCollider(myPoint, true);
            myPoint.MyCollider.CustomScale = new Vector3(5.0f, 0.0f, 0.0f);
            myPoint.MyPhysicalObject       = new PhysicalObject(myPoint, 0.0f, 0.0f, false);

            ResourceManager.Instance.CurrentScene.PointLights.Add(myPoint);

            foreach (GameObject obj in ResourceManager.Instance.CurrentScene.ObjectsDictionary.Values)
            {
                if (obj.Name.Contains("Street") && !obj.LightsAffecting.Contains(myPoint) &&
                    Vector3.Distance(MyObject.MyTransform.PositionGlobal, obj.MyTransform.PositionGlobal) <= 20.0f)
                {
                    myPoint.AffectedObjects.Add(obj);
                    obj.LightsAffecting.Add(myPoint);
                }
            }

            base.Initialize();
        }
        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();
        }
        public override void Initialize()
        {
            myPoint = new LightPoint(110, "LightPoint1", Color.Green.ToVector3(), Color.Green.ToVector3(), 10.0f, false);
            MyObject.AddChild(myPoint);
            myPoint.MyTransform            = new Transform(myPoint, new Vector3(0.0f, 0.25f, 0.0f), new Vector3(0.0f, 1.0f, 0.0f), new Vector3(0.0f, 0.0f, 0.0f), 4.0f);
            myPoint.MyCollider             = new SphereCollider(myPoint, true);
            myPoint.MyCollider.CustomScale = new Vector3(6.0f, 0.0f, 0.0f);
            myPoint.MyPhysicalObject       = new PhysicalObject(myPoint, 0.0f, 0.0f, false);

            ResourceManager.Instance.CurrentScene.PointLights.Add(myPoint);

            foreach (GameObject obj in ResourceManager.Instance.CurrentScene.ObjectsDictionary.Values)
            {
                if (obj.Name.Contains("Street") && !obj.LightsAffecting.Contains(myPoint) &&
                    Vector3.Distance(MyObject.MyTransform.PositionGlobal, obj.MyTransform.PositionGlobal) <= 25.0f)
                {
                    myPoint.AffectedObjects.Add(obj);
                    obj.LightsAffecting.Add(myPoint);
                }
            }

            base.Initialize();
        }
        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();
        }
Beispiel #5
0
        public override void Initialize()
        {
            if (type != WeaponType.FISTS)
            {
                myPoint = new LightPoint(110, "LightPoint1", Color.Orange.ToVector3(), Color.Orange.ToVector3(), 6.0f, false);
                MyObject.AddChild(myPoint);
                myPoint.MyTransform            = new Transform(myPoint, new Vector3(0.0f, 0.25f, 0.0f), new Vector3(0.0f, 1.0f, 0.0f), new Vector3(0.0f, 0.0f, 0.0f), 1.0f);
                myPoint.MyCollider             = new SphereCollider(myPoint, true);
                myPoint.MyCollider.CustomScale = new Vector3(5.0f, 0.0f, 0.0f);
                myPoint.MyPhysicalObject       = new PhysicalObject(myPoint, 0.0f, 0.0f, false);

                ResourceManager.Instance.CurrentScene.PointLights.Add(myPoint);

                foreach (GameObject obj in ResourceManager.Instance.CurrentScene.ObjectsDictionary.Values)
                {
                    if (obj.Name.Contains("Street") && !obj.LightsAffecting.Contains(myPoint) &&
                        Vector3.Distance(MyObject.MyTransform.PositionGlobal, obj.MyTransform.PositionGlobal) <= 20.0f)
                    {
                        myPoint.AffectedObjects.Add(obj);
                        obj.LightsAffecting.Add(myPoint);
                    }
                }
            }


            this.player = ResourceManager.Instance.CurrentScene.GetObject(1);
            if (this.player != null)
            {
                this.pc = (PlayerController)this.player.GetComponent <PlayerController>();
            }

            if (ParticleTexturePaths != null && ParticleTexturePaths.Count() != 0)
            {
                int        pCount = ParticleTexturePaths.Count();
                GameObject dupa   = new GameObject(132453245, "asfoieasjhgeowisughasaedokfgheasiourfdseyhaeyogfiuhsweoiughdseifoluh");
                ps = new ParticleSystem(this.MyObject);

                for (int i = 0; i < pCount; ++i)
                {
                    ps.Textures.Add(ResourceManager.Instance.LoadTexture(ParticleTexturePaths[i]));
                }

                ps.ParticleCount         = 20;
                ps.ParticleSize          = new Vector2(0.3f, 0.3f);
                ps.ParticleSizeVariation = new Vector2(0.2f, 0.2f);
                ps.LifespanSec           = 0.8f;
                ps.Wind             = new Vector3(0.0f, 0.0f, 0.0f);
                ps.Offset           = new Vector3(MathHelper.Pi);
                ps.Speed            = 2.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.00000005f;
                ps.Initialize();

                ps.Stop();

                dupa.Components.Add(ps);
                dupa.MyTransform = new Transform(dupa);

                MyObject.AddChild(dupa);
            }


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

            if (DestroyCueName != null && !TrashSoupGame.Instance.EditorMode)
            {
                jeb = Engine.AudioManager.Instance.SoundBank.GetCue(DestroyCueName);
            }

            base.Initialize();
        }