Exemplo n.º 1
0
    static void OnEntitySync(uint entityid, byte command, ref VectorArr vec)
    {
        NativeEntity entity = NativeEntityMgr.singleton.Get(entityid);

        switch (command)
        {
        case ASCII.p:
            Vector3 pos = vec.ToVector();
            pos.y = NativeScene.singleton.TerrainY(pos);
            entity.transfrom.position = pos;
            break;

        case ASCII.s:
            entity.transfrom.localScale = vec.ToVector();
            break;

        case ASCII.r:
            entity.transfrom.rotation = Quaternion.Euler(vec.ToVector());
            break;

        case ASCII.f:
            entity.transfrom.forward = vec.ToVector();
            break;

        default:
            XDebug.LogError("not regist command ", command);
            break;
        }
    }
Exemplo n.º 2
0
    static void OnComponentCallback(uint entityid, byte command, string arg)
    {
        NativeEntity entity = NativeEntityMgr.singleton.Get(entityid);

        switch (command)
        {
        case ASCII.C:
        {
            NativeEquipComponent ne = entity.GetComponent <NativeEquipComponent>();
            ne.ChangeHairColor(Color.red);
        }
        break;

        case ASCII.W:
        {
            NativeEquipComponent ne = entity.GetComponent <NativeEquipComponent>();
            ne.AttachWeapon(arg);
        }
        break;

        default:
            XDebug.LogError("not regist command ", command);
            break;
        }
    }
Exemplo n.º 3
0
 public void RemoveHighlight()
 {
     if (!controller.Occupied)
     {
         NativeEntity.SetSlotMaterial(slotInteractionPlate, AssetLibrary.Materials.GreyMin);
     }
 }
Exemplo n.º 4
0
        protected override void OnSetUnitData(UnitData unitData)
        {
            base.OnSetUnitData(unitData);

            // When the tower's unit data is set, set the material to the first object in it's UpgradPath data.
            NativeEntity.SetMaterial(CurrentTower.Material);
        }
Exemplo n.º 5
0
        public void Setup()
        {
            Cells.ForEach(x => x.Controller.Destroy());
            Cells.Clear();

            if (Rows == 0 || Columns == 0 || CellSize == 0)
            {
                return;
            }

            var pos = NativeEntity.GetPos();

            // Set origin to top-left corner of the grid. This is so the pivot of the object can remain at the center.
            var origin = new Vec3(pos.x - (float)(Columns / 2) * CellSize, pos.y + (float)(Rows / 2) * CellSize, 0f);

            for (int x = 0; x < Columns; x++)
            {
                for (int y = 0; y < Rows; y++)
                {
                    //var view = GameObject.Instantiate<ConstructionPoint>();
                    //var cell = new ConstructionPoint(new Vec3(origin.x + (x * CellSize) + CellSize / 2, origin.y - (y * CellSize) - CellSize / 2, 0), Quat.Identity, 1, view);
//                    Cells.Add(cell);
                }
            }
        }
Exemplo n.º 6
0
 public void SetUnitData(UnitData unitData)
 {
     UnitData = unitData;
     Health.SetMaxHealth(unitData.MaxHealth);
     Health.SetHealth(unitData.MaxHealth);
     NativeEntity.LoadGeometry(0, unitData.Mesh);
     NativeEntity.SetMaterial(unitData.Material);
     OnSetUnitData(unitData);
 }
Exemplo n.º 7
0
        public static string CreateNativeUrl(NativeEntity nativeEntity, string key)
        {
            var param = Utils.EntityToDictionary(nativeEntity); //将实体转换成数据集合

            param.Add("sign", Utils.GetPaySign(param, key));    //生成签名,并将签名添加到数据集合
            var arr = param.Select(p => p.Key + "=" + p.Value);

            return(string.Format("weixin://wxpay/bizpayurl?{0}", string.Join("&", arr)));
        }
Exemplo n.º 8
0
        public override void OnInitialize()
        {
            base.OnInitialize();

            NativeEntity.LoadGeometry(0, "objects/default/primitive_sphere.cgf");
            Scale                        = Vec3.One * 0.5f;
            collisionListener            = AddComponent <CollisionListener>();
            collisionListener.OnCollide += OnCollide;
        }
Exemplo n.º 9
0
//        GameObject core;

        public override void OnInitialize()
        {
            base.OnInitialize();

            Health = new Health();
            NativeEntity.LoadGeometry(0, AssetLibrary.Meshes.BasePlate);
            NativeEntity.SetMaterial(AssetLibrary.Materials.BasePlate);

            NativeEntity.LoadGeometry(1, AssetLibrary.Meshes.Diamond);
            NativeEntity.SetSlotMaterial(1, AssetLibrary.Materials.BaseCore);
            NativeEntity.SetSlotLocalTM(1, Matrix34.Create(Vec3.One, Quat.Identity, new Vec3(0, 0, 2f)));
        }
Exemplo n.º 10
0
    public override void OnInitial(NativeEntity enty)
    {
        base.OnInitial(enty);

        //时装
        TempEquipSuit fashions = new TempEquipSuit();

        m_FashionList = new List <EquipPart>();
        var fashionsuit = XTableMgr.GetTable <FashionSuit>();

        for (int i = 0, max = fashionsuit.length; i < max; ++i)
        {
            FashionSuit.RowData row = fashionsuit[i];
            if (row.FashionID != null)
            {
                XEquipUtil.MakeEquip(row.SuitName, row.FashionID, m_FashionList, fashions, (int)row.SuitID);
            }
        }

        //装备
        m_EquipList = new List <EquipPart>();
        var equipsuit = XTableMgr.GetTable <EquipSuit>();

        for (int i = 0, max = equipsuit.length; i < max; ++i)
        {
            EquipSuit.RowData row = equipsuit[i];
            if (row.EquipID != null)
            {
                XEquipUtil.MakeEquip(row.SuitName, row.EquipID, m_EquipList, fashions, -1);
            }
        }

        Transform skinmesh = enty.transfrom;

        skin = skinmesh.GetComponent <SkinnedMeshRenderer>();
        if (skin == null)
        {
            skin = skinmesh.gameObject.AddComponent <SkinnedMeshRenderer>();
        }
        skin.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.On;
        enty.skin = skin;

        for (EPartType part = EPartType.ECombinePartStart; part < EPartType.ECombinePartEnd; ++part)
        {
            parts[(int)part] = new PartLoadTask(part, this);
        }
        for (EPartType part = EPartType.ECombinePartEnd; part < EPartType.EMountEnd; ++part)
        {
            parts[(int)part] = new MountLoadTask(part, this);
        }
        EquipPart(m_FashionList[0]);
    }
Exemplo n.º 11
0
        public override void OnInitialize()
        {
            base.OnInitialize();

            // Load default geometry.
            NativeEntity.LoadGeometry(0, "objects/default/primitive_sphere.cgf");

            // Load default material.
            NativeEntity.SetMaterial("materials/matref_chrome128.mtl");

            // Physicalize.
            Physics.Physicalize(10, EPhysicalizationType.ePT_Rigid);
        }
Exemplo n.º 12
0
 /// <summary>
 /// Upgrades the tower if another upgrade is available.
 /// </summary>
 public void Upgrade()
 {
     if (NextTower != null)
     {
         NativeEntity.SetMaterial(NextTower.Material);
         SetupWeapon();
         Level++;
     }
     else
     {
         Log.Warning("Cannot Upgrade unit because there is no upgrade path!");
     }
 }
Exemplo n.º 13
0
 public override void OnInitial(NativeEntity enty)
 {
     base.OnInitial(enty);
     m_Animator = entity.EntityObject.GetComponent <Animator>();
     if (m_Animator.runtimeAnimatorController is AnimatorOverrideController)
     {
         m_overrideController = m_Animator.runtimeAnimatorController as AnimatorOverrideController;
     }
     else
     {
         m_overrideController = new AnimatorOverrideController();
         m_overrideController.runtimeAnimatorController = m_Animator.runtimeAnimatorController;
         m_Animator.runtimeAnimatorController           = m_overrideController;
     }
     m_Animator.Rebind();
 }
Exemplo n.º 14
0
        public override void OnInitialize()
        {
            base.OnInitialize();

            collisionListener            = AddComponent <CollisionListener>();
            collisionListener.OnCollide += CollisionListener_OnCollide;

            NativeEntity.LoadGeometry(0, "objects/default/primitive_sphere.cgf");

            var physParams = new SEntityPhysicalizeParams()
            {
                density = 1,
                mass    = 10,
                type    = (int)EPhysicalizationType.ePT_Rigid,
            };

            NativeEntity.Physicalize(physParams);
        }
Exemplo n.º 15
0
        public override void OnInitialize()
        {
            var physParams = new SEntityPhysicalizeParams()
            {
                mass    = -1,
                density = -1,
                type    = (int)EPhysicalizationType.ePT_Rigid,
            };

            // Create the mesh that responds to mouse interaction
            NativeEntity.LoadGeometry(slotInteractionPlate, AssetLibrary.Meshes.Hexagon);
            NativeEntity.SetSlotMaterial(slotInteractionPlate, AssetLibrary.Materials.GreyMin);

            // Create the BasePlate that represents the Construction Point.
            NativeEntity.LoadGeometry(slotBasePlate, AssetLibrary.Meshes.BasePlate);
            NativeEntity.SetSlotMaterial(slotBasePlate, AssetLibrary.Materials.BasePlate);

            NativeEntity.Physicalize(physParams);
        }
Exemplo n.º 16
0
        public void Launch()
        {
            GetParticleEffect("particle_trail", (pfx) => NativeEntity.LoadParticleEmitter(1, pfx));

            // Launch the firework upwards.
            Physics.Action <pe_action_impulse>((action) =>
            {
                action.impulse = Rotation.Forward * 100f;
            });

            var rnd = new Random().Next((int)MinTime * 100, (int)MaxTime * 100) / 100f;

            // Start a timer that will trigger the explosion.
            new Timer(rnd, () =>
            {
                // Spawn the explosion effect then remove this entity.
                GetParticleEffect("particle_explosion", (pfx) => pfx.Spawn(Position));
                Remove();
            });
        }
Exemplo n.º 17
0
 public virtual void OnInitial(NativeEntity enty)
 {
     entity = enty;
 }
Exemplo n.º 18
0
 void Controller_OnUnitRemoved(Unit unit)
 {
     NativeEntity.SetSlotMaterial(slotInteractionPlate, AssetLibrary.Materials.GreyMin);
 }
Exemplo n.º 19
0
        void Controller_OnOccupiedStateChanged()
        {
            var material = controller.Occupied ? AssetLibrary.Materials.Green : AssetLibrary.Materials.GreyMin;

            NativeEntity.SetSlotMaterial(slotInteractionPlate, material);
        }