Esempio n. 1
0
        private void TickProductUnit()
        {
            if (productUnitType == null)
            {
                return;
            }

            productUnitProgress += TickDelta / productUnitType.BuildTime;

            Degree angleDelta = TickDelta * 20;

            if (productUnitAttachedMesh != null)
            {
                productUnitAttachedMesh.RotationOffset *= new Angles(0, 0, angleDelta).ToQuat();
            }

            if (BuildUnitProgress >= 1)
            {
                CreateProductedUnit();
                StopProductUnit();
            }

            MapObjectAttachedObject buildPlatformMesh = GetFirstAttachedObjectByAlias("buildPlatform");

            if (buildPlatformMesh != null)
            {
                buildPlatformMesh.RotationOffset *= new Angles(0, 0, angleDelta).ToQuat();
            }
        }
Esempio n. 2
0
        void CreateThreads()
        {
            for (int n = 1; ; n++)
            {
                MapObjectAttachedObject startObject = GetFirstAttachedObjectByAlias(string.Format("thread{0}Start", n));
                MapObjectAttachedObject endObject   = GetFirstAttachedObjectByAlias(string.Format("thread{0}End", n));
                if (startObject == null || endObject == null)
                {
                    break;
                }

                MeshObject meshObject = SceneManager.Instance.CreateMeshObject("Base\\Simple Models\\Box.mesh");
                if (meshObject == null)
                {
                    break;
                }

                meshObject.SetMaterialNameForAllSubObjects("Black");
                meshObject.CastShadows = true;

                ThreadItem item = new ThreadItem();
                item.startObject = startObject;
                item.endObject   = endObject;
                item.meshObject  = meshObject;
                item.sceneNode   = new SceneNode();
                item.sceneNode.Attach(item.meshObject);

                MapObject.AssociateSceneNodeWithMapObject(item.sceneNode, this);

                threads.Add(item);
            }

            UpdateThreads();
        }
Esempio n. 3
0
        protected override void OnPostCreate(bool loaded)
        {
            base.OnPostCreate(loaded);

            if (EntitySystemWorld.Instance.IsClientOnly())
            {
                MapObjectAttachedObject attachedObject = GetFirstAttachedObjectByAlias("clientNotSupported");
                if (attachedObject != null)
                {
                    attachedObject.Visible = true;
                }
            }
        }
Esempio n. 4
0
        void CreateProductUnitAttachedMesh()
        {
            productUnitAttachedMesh = new MapObjectAttachedMesh();
            Attach(productUnitAttachedMesh);

            string meshName   = null;
            Vec3   meshOffset = Vec3.Zero;
            Vec3   meshScale  = new Vec3(1, 1, 1);

            {
                foreach (MapObjectTypeAttachedObject typeAttachedObject in
                         productUnitType.AttachedObjects)
                {
                    MapObjectTypeAttachedMesh typeAttachedMesh =
                        typeAttachedObject as MapObjectTypeAttachedMesh;
                    if (typeAttachedMesh == null)
                    {
                        continue;
                    }

                    meshName   = typeAttachedMesh.MeshName;
                    meshOffset = typeAttachedMesh.Position;
                    meshScale  = typeAttachedMesh.Scale;
                    break;
                }
            }

            productUnitAttachedMesh.MeshName = meshName;

            Vec3 pos = meshOffset;

            {
                MapObjectAttachedObject buildPointAttachedHelper =
                    GetAttachedObjectByAlias("productUnitPoint");
                if (buildPointAttachedHelper != null)
                {
                    pos += buildPointAttachedHelper.PositionOffset;
                }
            }
            productUnitAttachedMesh.PositionOffset = pos;

            productUnitAttachedMesh.ScaleOffset = meshScale;

            if (Type.Name == "RTSHeadquaters")
            {
                foreach (MeshObject.SubObject subMesh in productUnitAttachedMesh.MeshObject.SubObjects)
                {
                    subMesh.MaterialName = "RTSBuildMaterial";
                }
            }
        }
Esempio n. 5
0
        private void lstWeaponList_SelectedIndexChange(ListBox sender)
        {
            if (lstWeaponList.SelectedItem == null)
            {
                return;
            }

            //get default weaponType on the selected slot
            AKunit u = spawner.Spawned as AKunit;

            AKunitType.WeaponItem          wi  = cbxWeaponSlots.SelectedItem as AKunitType.WeaponItem;
            AKunitType.AlternateWeaponItem awi = lstWeaponList.SelectedItem as AKunitType.AlternateWeaponItem;

            string selectedBodyPartName  = GetBodyPartNameFromActiveButton();
            int    selectedBodyPartIndex = GetBodyPartIndex(selectedBodyPartName);
            string weaponAlias           = wi.MapObjectAlias;

            MapObjectAttachedObject    o  = u.GetFirstAttachedObjectByAlias(weaponAlias);
            MapObjectAttachedMapObject mo = o as MapObjectAttachedMapObject;

            u.Detach(mo);

            Weapon w = Entities.Instance.Create(awi.WeaponType, Map.Instance) as Weapon;

            w.PostCreate();
            MapObjectAttachedMapObject amo = new MapObjectAttachedMapObject();

            amo.MapObject      = w;
            amo.PositionOffset = mo.PositionOffset;
            amo.Alias          = mo.Alias;
            amo.Body           = mo.Body;
            amo.BoneSlot       = mo.BoneSlot;
            amo.RotationOffset = mo.RotationOffset;
            amo.ScaleOffset    = mo.ScaleOffset;

            u.Attach(amo);

            Gun   g          = w as Gun;
            float multiplier = 1 / g.Type.NormalMode.BetweenFireTime;
            float rateOfFire = multiplier;

            if (g.Type.NormalMode.BulletExpense != 0)
            {
                rateOfFire = rateOfFire * g.Type.NormalMode.BulletExpense;
            }

            txtWeaponInfo.Text = string.Format(
                "Weapon Name: {0}\r\nWeapon Type: {1}\r\nDamage: {2}\r\nHeat: {3}\r\nRate of Fire: {4}\r\nPrice: {5}",
                w.Type.Name, "Not Implemented", g.Type.NormalMode.BulletType.Damage, g.Type.NormalMode.AKGunHeatGeneration, rateOfFire.ToString("F1"), awi.Price);
        }