Beispiel #1
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();
        }
Beispiel #2
0
    void AddNewUnit(MyObject myObject)
    {
        aIMoveComponents.Add(myObject.GetComponent <AIMoveComponent>());
        if (aIMoveComponents.Count >= 6)
        {
            foreach (AIMoveComponent aIMoveComponent in aIMoveComponents)
            {
                aIMoveComponent.MoveToHQ();
            }

            aIMoveComponents.Clear();
        }
    }
Beispiel #3
0
 void UpdatePlayer(MyObject obj, Player player)
 {
     var rb = obj.GetComponent <Rigidbody>();
     var v  = rb.velocity;
     // if (0f < v.y) {
     //  v.y = 0f;
     //  rb.velocity = v;
     // }
     // var pos = rb.position;
     // if (0f < pos.y) {
     //  pos.y = 0f;
     //  rb.position = pos;
     // }
 }
Beispiel #4
0
    private void Update()
    {
        if (!GetComponent <MyObject>().active)
        {
            return;
        }

        if (targetEnemy == null || targetAttackableComponent == null)
        {
            FindTargetEnemy();
        }

        attackRateCurr += Time.deltaTime;
        if (attackRateCurr > attackRateMax)
        {
            //if (targetEnemy == null || targetAttackableComponent == null) {
            //    FindTargetEnemy();
            //}

            if (targetEnemy != null && targetAttackableComponent != null)
            {
                attackRateCurr = 0;
                MoveToAndDestroy moveToAndDestroy = Instantiate(bullet, firePoint.transform.position, firePoint.rotation).GetComponent <MoveToAndDestroy>();
                moveToAndDestroy.init(targetEnemy.GetComponent <AttackableComponent>(), GetComponent <MyObject>().myObjectType, 100f, damage);
            }
            else
            {
                if (audioSource != null)
                {
                    if (audioSource.isPlaying)
                    {
                        audioSource.Stop();
                    }
                }
            }
        }

        if (weapon != null && targetEnemy != null)
        {
            weapon.transform.LookAt(targetEnemy.transform);
        }
    }
    IEnumerator LoadImage(string ImageName)
    {
        using (UnityWebRequest uwr = UnityWebRequestTexture.GetTexture("file:///C:/MyFilePath" + ImageName + ".jpg"))
        {
            yield return(uwr.SendWebRequest());

            if (uwr.isNetworkError || uwr.isHttpError)
            {
                Debug.Log(uwr.error);
            }
            else
            {
                // Get downloaded texture
                var texture = DownloadHandlerTexture.GetContent(uwr);

                // now use it
                MyObject.GetComponent <Image>().material       = texture;
                GetComponent <Renderer>().material.mainTexture = tex;
            }
        }
    }
Beispiel #6
0
        void UpdateStone(MyObject obj, Stone stone)
        {
            var rb = obj.GetComponent <Rigidbody>();

            if (!rb.isKinematic)
            {
                return;
            }
            var t     = Mathf.Clamp01(obj.time / stone.duration);
            var pos   = easingJump(stone.startPosition, stone.targetPosition, 1f, t);
            var delta = pos - rb.position;

            if (1f <= t || obj.stone.hasHit)
            {
                rb.velocity    = delta;
                rb.isKinematic = false;
            }
            else
            {
                rb.position += delta;
            }
        }
Beispiel #7
0
    public void NewTarget(MyObject trgt)
    {
        Creature target = trgt.GetComponent <Creature>();

        if (target == null)
        {
            return;
        }
        float Chance = UnityEngine.Random.Range(0, 100);

        Chance += (int)StartEntityType * 3;
        Debug.Log("My chance  " + Chance);
        if (Targets.Count == 3)
        {
            Debug.Log("HHHEEEEYYY_______12345678");
            if (Chance == 115)
            {
                CurrentEntityType = SkillBehaviourType.FuriousAttack;
            }
            else if (Chance >= 110)
            {
                CurrentEntityType = SkillBehaviourType.RunAway;
            }
            else
            {
                CurrentEntityType--;
            }
        }
        if (Targets.Count == 5)
        {
            if (Chance >= 110)
            {
                CurrentEntityType = SkillBehaviourType.FuriousAttack;
            }
            else if (Chance >= 90)
            {
                CurrentEntityType = SkillBehaviourType.RunAway;
            }
            else
            {
                CurrentEntityType--;
            }
        }
        if (Targets.Count == 10)
        {
            if (Chance >= 50)
            {
                CurrentEntityType = SkillBehaviourType.RunAway;
            }
            else if (Chance >= 25)
            {
                CurrentEntityType = SkillBehaviourType.FuriousAttack;
            }
            else
            {
                CurrentEntityType = SkillBehaviourType.DeefDefend;
            }
        }
        if (CurrentEntityType == SkillBehaviourType.FuriousAttack)
        {
            Debug.Log("Heyy");
            return;
        }
        float Power = CheckEnemy(target);

        Debug.Log("Enemy power:  " + Power);
        if (Power > 500)
        {
            if (Chance > 110)
            {
                CurrentEntityType = SkillBehaviourType.DeefDefend;
            }
            else
            {
                CurrentEntityType = SkillBehaviourType.RunAway;
            }
            return;
        }
        if (Power > 250)
        {
            if (Chance > 80)
            {
                CurrentEntityType = SkillBehaviourType.DeefDefend;
            }
            else if (Chance > 10)
            {
                CurrentEntityType = SkillBehaviourType.RunAway;
            }
            else
            {
                CurrentEntityType--;
            }
            return;
        }
        if (Power > 100)
        {
            return;
        }
        if (Power < 100)
        {
            SituationSkill++;
            CurrentEntityType++;
            return;
        }
    }
Beispiel #8
0
    protected void Update()
    {
        if (spawnQueue.Count > 0 || objectToSpawn != null)
        {
            if (objectToSpawn == null)
            {
                currentSpawnQueueItem = spawnQueue.Dequeue();
                objectToSpawn         = currentSpawnQueueItem.thingToSpawn;
                UICoolDownImage       = currentSpawnQueueItem.UICooldownImage;
                UICoolDownImage.color = new Color(1, 0, 0, (float)122 / 255);
                hasPlayedAudio        = false;
                queueLength           = currentSpawnQueueItem.queueLength;
                currentSpawnQueueItem.Dequeue();
                if (FactoryDoor != null)
                {
                    FactoryDoor.TurnOnLights();
                }
            }
            spawntimerCurr += Time.deltaTime;

            if (spawntimerCurr > spawntimerMax)
            {
                spawntimerCurr = spawntimerMax;
                if (!manuallyPlaced)
                {
                    spawntimerCurr = 0;
                    UICoolDownImage.rectTransform.sizeDelta = new Vector2(UICoolDownImage.rectTransform.sizeDelta.x, 0);

                    MyObject tmp = Instantiate(objectToSpawn, spawnPoint.position, Quaternion.identity);
                    tmp.Activate();
                    OnUnitSpawned?.Invoke(tmp);
                    objectToSpawn         = null;
                    currentSpawnQueueItem = null;
                    tmp.team = GetComponent <MyObject>().team;
                    tmp.GetComponent <UnityEngine.AI.NavMeshAgent>().destination = waypointLocation.position;

                    if (FactoryDoor != null)
                    {
                        FactoryDoor.OpenDoor();
                    }
                }
                else
                {
                    if (!hasPlayedAudio)
                    {
                        hasPlayedAudio        = true;
                        UICoolDownImage.color = new Color(0, 1, 0, (float)122 / 255);
                        constructionComplete.Play();
                        //UICoolDownImage.transform.parent.SetAsLastSibling();
                        iTween.PunchScale(UICoolDownImage.transform.parent.gameObject, new Vector3(2f, 2f, 2f), 1f);
                    }
                }
            }

            float spriteSizeFrac = (spawntimerCurr / spawntimerMax);
            UICoolDownImage.rectTransform.sizeDelta = new Vector2(UICoolDownImage.rectTransform.sizeDelta.x, spriteMaxSize * spriteSizeFrac);
        }
        else
        {
            spawntimerCurr = 0;
        }
    }
Beispiel #9
0
    public void AddAvatarPedestals()
    {
        GameObject         MyObject, MyParentObject = null;
        VRC_AvatarPedestal MyAvatarScript;
        Vector3            V = new Vector3();
        int i, l, m, n, k, CurrentRow = 0, CurrentReset = 0, CurrentReset2 = 0;

        MeshRenderer[] MyMeshRenderers;
        Material[]     MyMaterials;

        if (SelectedObject == null)
        {
            CustomMessage = "You've To Select Avatar Pedestal";
            return;
        }

        MyAvatarScript = SelectedObject.GetComponent <VRC_AvatarPedestal>();

        if (MyAvatarScript == null)
        {
            CustomMessage = "VRC_AvatarPedestal Script Not Found. Select Correct Avatar Pedestal";
            return;
        }

        if (UsedName == "" || UsedTag == "")
        {
            CustomMessage = "You've To Set Used Name And Used Tag";
            return;
        }

        CustomMessage = "";
        PendingAvatarPedestals.Clear();

        for (i = 0; i < ListOfAvatarIDs.Count; i++)
        {
            if (i > 0 && i % LengthOfRow == 0)
            {
                CurrentRow++;

                if (CurrentRow == MaxRows)
                {
                    CurrentRow = 0;
                    CurrentReset++;

                    if (CurrentReset == MaxResets)
                    {
                        CurrentReset = 0;
                        CurrentReset2++;
                    }
                }
            }

            V             = StartPosition + (i % LengthOfRow) * OffsetByIndex + OffsetByRow * CurrentRow + OffsetByReset * CurrentReset + OffsetByReset2 * CurrentReset2;
            MyObject      = Instantiate(SelectedObject, V, SelectedObject.transform.rotation);
            MyObject.name = Repl(UsedName, "%Index%", i.ToString());
            MyObject.tag  = UsedTag;
            MyObject.SetActive(!bDefaultHide);

            if (bKeepParentObject)
            {
                if (SelectedObject.transform.parent != null)
                {
                    MyParentObject = SelectedObject.transform.parent.gameObject;
                }
            }
            else
            {
                MyParentObject = ParentObject;
            }

            if (MyParentObject != null && MyParentObject.transform != null)
            {
                MyObject.transform.SetParent(MyParentObject.transform, bWorldPositionStays);
            }

            if (CustomMeterialsByID.List.Count > 0)
            {
                for (m = 0; m < CustomMeterialsByID.List.Count; m++)
                {
                    for (n = 0; n < CustomMeterialsByID.List[m].ListOfIDs.Count; n++)
                    {
                        if (CustomMeterialsByID.List[m].ListOfIDs[n] == ListOfAvatarIDs[i])
                        {
                            MyMeshRenderers = MyObject.GetComponentsInChildren <MeshRenderer>(true);

                            for (k = 0; k < MyMeshRenderers.Length; k++)
                            {
                                MyMaterials = MyMeshRenderers[k].materials;

                                for (l = 0; l < MyMaterials.Length; l++)
                                {
                                    MyMaterials[l] = CustomMeterialsByID.List[m].M;
                                }

                                MyMeshRenderers[k].materials = MyMaterials;
                            }
                        }
                    }
                }
            }

            MyAvatarScript             = MyObject.GetComponent <VRC_AvatarPedestal>();
            MyAvatarScript.blueprintId = ListOfAvatarIDs[i];

            if (bActivateByTrigger)
            {
                PendingAvatarPedestals.Add(MyObject);
            }
        }

        if (bActivateByTrigger)
        {
            AddAvatarPedestalsToTrigger();
        }
    }
Beispiel #10
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();
        }
Beispiel #11
0
 public void Deselect(MyObject objectToDeselect)
 {
     selectedObjects.Remove(objectToDeselect.GetComponent <SelectableComponent>());
 }