コード例 #1
0
        }                       // set player reference

        /// <summary>
        /// Called on equipment update
        /// </summary>
        /// <param name="op">Operation (SET/UPDATE/REMOVE...)</param>
        /// <param name="key">Equipment slot</param>
        /// <param name="item">Item data</param>
        public static void OnEquipmentUpdate(SyncIDictionary <EquipmentSlot, ItemData> .Operation op, EquipmentSlot key, ItemData item)
        {
            switch (op)
            {
            case SyncIDictionary <EquipmentSlot, ItemData> .Operation.OP_SET:
            case SyncIDictionary <EquipmentSlot, ItemData> .Operation.OP_ADD:
                Equipment equipment = (Equipment)ObjectDatabase.GetItem(item.ID);
                if (equipment)
                {
                    Instance.SetIcon(key, equipment.icon);
                }
                break;

            case SyncIDictionary <EquipmentSlot, ItemData> .Operation.OP_REMOVE:
                Instance.SetIcon(key, null);
                break;
            }
        }
コード例 #2
0
        public void ServerFireAtTarget(uint attackerEntityID, uint targetEntityID, short weaponID, bool rotateToTarget = true)
        {
            Weapon weapon = ObjectDatabase.GetWeapon(weaponID);

            if (weapon)
            {
                Entity targetEntity   = ObjectDatabase.GetEntity(targetEntityID);
                Entity attackerEntity = ObjectDatabase.GetEntity(attackerEntityID);

                if (!targetEntity || !attackerEntity)
                {
                    return;
                }

                // bullet
                RpcFireAtTarget(attackerEntityID, targetEntityID, weaponID, rotateToTarget);

                GameObject bullet = Instantiate(weapon.bulletPrefab, attackerEntity.transform.position, Quaternion.identity);

                BulletController bulletController = bullet.GetComponent <BulletController>();
                bulletController.ServerSetTarget(targetEntity.transform, weapon.bulletSpeed, weapon.Damage, attackerEntityID, targetEntityID);
            }
        }