Exemplo n.º 1
0
 public void StartCrafting()
 {
     if (playerCharacter.craftingEnabled)
     {
         CraftingSpot craftingSpot = playerCharacter.craftingSpot.GetComponent <CraftingSpot>();
         crafting     = !crafting;
         craftingType = craftingSpot.skillType;
         string animName = CraftingTypeToAnimation(craftingType);
         anim.SetBool(animName, crafting);
         SwitchTool(craftingType);
         return;
     }
 }
Exemplo n.º 2
0
    private void OnTriggerExit(Collider other)
    {
        if (other.tag.Equals("Resource"))
        {
            currentResource  = null;
            gatheringEnabled = false;
        }
        else if (other.tag.Equals("Dock"))
        {
            dock     = null;
            isOnDock = false;
        }
        else if (other.tag.Equals("CraftingSpot"))
        {
            craftingEnabled = false;
            craftingSpot    = null;
        }
        else if (other.tag == "Trader")
        {
            tradingEnabled = false;
            trader         = null;
        }
        else if (other.tag == "TradeBroker")
        {
            tradeBrokerEnabled = false;
        }
        else if (other.name.Equals("PlayerSphere"))
        {
            int otherPlayerId = other.GetComponentInParent <PlayerCharacter>().id;

            if (otherPlayerId != id)
            {
                ServerSend.DeactivatePlayerCharacter(id, otherPlayerId);
            }
        }
        else if (other.name.Equals("Sphere"))
        {
            int otherPlayerId = other.GetComponentInParent <Player>().id;

            if (otherPlayerId != id)
            {
                ServerSend.DeactivateShip(id, otherPlayerId);
            }
        }
        else if (other.name.Equals("NPCSphere"))
        {
            int npcId = other.GetComponentInParent <NPC>().id;
            ServerSend.DeactivateNPC(id, npcId);
        }
    }
Exemplo n.º 3
0
 public static void RequestCraftingResponse(int to, CraftingSpot craftingSpot)
 {
     using (Packet _packet = new Packet((int)ServerPackets.requestCraftingResponse))
     {
         if (craftingSpot != null)
         {
             _packet.Write(true);
             _packet.Write((int)craftingSpot.skillType);
             _packet.Write(GameServer.clients[to].player.skills);
         }
         else
         {
             _packet.Write(false);
         }
         SendTCPData(to, _packet);
     }
 }
Exemplo n.º 4
0
    public static void SpawnGameObject(int _toClient, SpawnManager.Spawn spawn)
    {
        using (Packet _packet = new Packet((int)ServerPackets.spawnGameObject))
        {
            _packet.Write(spawn.id);
            _packet.Write(Convert.ToInt32(spawn.type));
            _packet.Write(spawn.gameObject.transform.position);
            _packet.Write(spawn.gameObject.transform.rotation);
            _packet.Write((int)spawn.objectType);

            if (spawn.objectType == ObjectType.RESOURCE)
            {
                Resource resource = spawn.gameObject.GetComponent <Resource>();
                _packet.Write(resource.respawning);
                _packet.Write(resource.gatheredTime);
                _packet.Write(resource.respawnTime);
                _packet.Write((int)resource.skill_type);
            }
            else if (spawn.objectType == ObjectType.TRADER)
            {
                Trader trader = spawn.gameObject.GetComponent <Trader>();
                _packet.Write(trader.id);
            }
            else if (spawn.objectType == ObjectType.CRAFTING_SPOT)
            {
                CraftingSpot craftingSpot = spawn.gameObject.GetComponent <CraftingSpot>();
                _packet.Write((int)craftingSpot.skillType);
            }
            else if (spawn.objectType == ObjectType.NPC)
            {
                NPCStartParams params_ = spawn.gameObject.GetComponent <NPC>().GetStartParams();
                _packet.Write(params_);
            }

            SendTCPData(_toClient, _packet);
        }
    }
Exemplo n.º 5
0
    private void OnTriggerEnter(Collider other)
    {
        if (other.name.Equals("Sphere"))
        {
            int otherPlayerId = other.GetComponentInParent <Player>().id;

            if (otherPlayerId != id)
            {
                bool isOnShip = GameServer.clients[otherPlayerId].player.data.is_on_ship;

                /*if (isOnShip)
                 * {
                 *  ServerSend.DestroyPlayerCharacter(id, otherPlayerId);
                 * }*/
                ServerSend.ActivateShip(id, otherPlayerId);
                ServerSend.Stats(otherPlayerId, id);
                ServerSend.Buffs(otherPlayerId, id);
            }
        }
        else if (other.name.Equals("PlayerSphere"))
        {
            int otherPlayerId = other.GetComponentInParent <PlayerCharacter>().id;

            if (otherPlayerId != id)
            {
                ServerSend.ActivatePlayerCharacter(id, otherPlayerId);
                ServerSend.Stats(otherPlayerId, id);
                ServerSend.Buffs(otherPlayerId, id);
                Player player = GameServer.clients[otherPlayerId].player;
                if (player.playerMovement.agent.enabled)
                {
                    ServerSend.DeactivatePlayerMovement(otherPlayerId, player.playerInstance.transform.position);
                }
                else
                {
                    ServerSend.ActivatePlayerMovement(otherPlayerId, player.playerInstance.transform.position);
                }
            }
        }
        else if (other.tag.Equals("Resource"))
        {
            gatheringEnabled = true;
            currentResource  = other.gameObject;
        }
        else if (other.tag.Equals("Dock"))
        {
            dock     = other.gameObject;
            isOnDock = true;
        }
        else if (other.tag.Equals("CraftingSpot"))
        {
            craftingEnabled = true;
            craftingSpot    = other.GetComponent <CraftingSpot>();
        }
        else if (other.tag == "Trader")
        {
            tradingEnabled = true;
            trader         = other.gameObject.GetComponent <Trader>();
        }
        else if (other.tag == "TradeBroker")
        {
            tradeBrokerEnabled = true;
        }
        else if (other.tag == "Weapon")
        {
            PlayerAttack.OnPlayerAttack(this, other);
        }
        else if (other.name.Equals("NPCSphere"))
        {
            int npcId = other.GetComponentInParent <NPC>().id;
            ServerSend.NPCStats(npcId, id);
            ServerSend.ActivateNPC(id, npcId);
        }
        else if (other.name.Equals("DamageCollider"))
        {
            NPC npc = other.GetComponentInParent <NPC>();
            DamageColliderInfo info = other.GetComponent <DamageColliderInfo>();
            NPCAttack.OnNPCAttack(info, npc, this);
        }
    }
Exemplo n.º 6
0
    // Start is called before the first frame update
    void Start()
    {
        List <ResourceSpawn> resourceSpawns       = mysql.ReadResourceSpawns();
        List <SerializableObjects.Trader> traders = mysql.ReadTraders();
        List <TradeBroker>       brokers          = mysql.ReadTradeBrokers();
        List <CraftingSpotSpawn> craftingSpots    = mysql.ReadCraftingSpots();
        List <NPCSpawn>          npcSpots         = mysql.ReadNPCSpawns();

        //create Chest prefab
        int        id    = NextId();
        GameObject chest = Instantiate(prefabs[GameObjectType.chest], new Vector3(-3.57f, -2f, -8.83f), Quaternion.identity);

        objects.Add(id, new Spawn()
        {
            id = id, type = GameObjectType.chest, gameObject = chest, objectType = ObjectType.CHEST
        });

        foreach (ResourceSpawn spawn in resourceSpawns)
        {
            id = NextId();
            GameObject go = Instantiate(prefabs[(GameObjectType)spawn.RESOURCE.RESOURCE_TYPE], new Vector3(spawn.X, spawn.Y, spawn.Z), Quaternion.identity);
            objects.Add(id, new Spawn()
            {
                id = id, type = (GameObjectType)spawn.RESOURCE.RESOURCE_TYPE, gameObject = go, objectType = ObjectType.RESOURCE
            });

            Item item = mysql.ReadItem(spawn.RESOURCE.ITEM_ID);

            Resource resource = go.GetComponent <Resource>();
            resource.maxHp         = spawn.RESOURCE.RESOURCE_HP;
            resource.resourceCount = spawn.RESOURCE.RESOURCE_COUNT;
            resource.respawnTime   = spawn.RESPAWN_TIME;
            resource.itemId        = spawn.RESOURCE.ITEM_ID;
            resource.skill_type    = (SkillType)spawn.RESOURCE.SKILL_TYPE;
            resource.experience    = spawn.RESOURCE.EXPERIENCE;
            resource.item          = item;

            resource.Initialize();
        }

        foreach (SerializableObjects.Trader trader in traders)
        {
            id = NextId();
            GameObject go = Instantiate(prefabs[(GameObjectType)trader.game_object_type], new Vector3(trader.x, trader.y, trader.z), Quaternion.identity);
            go.transform.eulerAngles = new Vector3(0, trader.y_rot, 0);
            objects.Add(id, new Spawn()
            {
                id = id, type = (GameObjectType)trader.game_object_type, gameObject = go, objectType = ObjectType.TRADER
            });

            Trader traderScript = go.GetComponent <Trader>();
            traderScript.id = trader.id;
        }

        foreach (TradeBroker broker in brokers)
        {
            id = NextId();
            GameObject go = Instantiate(prefabs[(GameObjectType)broker.game_object_type], new Vector3(broker.x, broker.y, broker.z), Quaternion.identity);
            go.transform.eulerAngles = new Vector3(0, broker.y_rot, 0);
            objects.Add(id, new Spawn()
            {
                id = id, type = (GameObjectType)broker.game_object_type, gameObject = go, objectType = ObjectType.TRADE_BROKER
            });
        }

        foreach (CraftingSpotSpawn craftingSpot in craftingSpots)
        {
            id = NextId();
            GameObject go = Instantiate(prefabs[(GameObjectType)craftingSpot.gameObjectType], new Vector3(craftingSpot.x, craftingSpot.y, craftingSpot.z), Quaternion.identity);
            go.transform.eulerAngles = new Vector3(0, craftingSpot.Y_rot, 0);
            objects.Add(id, new Spawn()
            {
                id = id, type = (GameObjectType)craftingSpot.gameObjectType, gameObject = go, objectType = ObjectType.CRAFTING_SPOT
            });

            CraftingSpot craftingSpotScript = go.GetComponent <CraftingSpot>();
            craftingSpotScript.skillType = craftingSpot.skillType;
        }

        land.BuildNavMesh();

        /*id = NextId();
         * GameObject palmTree = Instantiate(prefabs[GameObjectType.palmTree], new Vector3(32.62526f, 0.8707776f, 45.96268f), Quaternion.identity);
         * objects.Add(id, new Spawn() { id = id, type = GameObjectType.palmTree, gameObject = palmTree });
         *
         * id = NextId();
         * GameObject ironRock = Instantiate(prefabs[GameObjectType.ironRock], new Vector3(28.95738f, 0.64f, 48.02f), Quaternion.identity);
         * objects.Add(id, new Spawn() { id = id, type = GameObjectType.ironRock, gameObject = ironRock });
         *
         * id = NextId();
         * GameObject goldRock = Instantiate(prefabs[GameObjectType.goldRock], new Vector3(28.16f, 0.75f, 50.88757f), Quaternion.identity);
         * objects.Add(id, new Spawn() { id = id, type = GameObjectType.goldRock, gameObject = goldRock });*/
        /*
         * id = NextId();
         * GameObject ai = Instantiate(prefabs[GameObjectType.npcShip], new Vector3(0f, 0f, 0f), Quaternion.identity);
         * objects.Add(id, new Spawn() { id = id, type = GameObjectType.npcShip, gameObject = ai });
         * EnemyAI enemy = ai.GetComponent<EnemyAI>();
         * enemy.id = id;
         * Server.npcs.Add(id, enemy);*/


        /*foreach (NPCSpawn spawn in npcSpots)
         * {
         *  if (spawn.enabled)
         *  {
         *      id = NextId();
         *      GameObject go = Instantiate(prefabs[(GameObjectType)spawn.gameObjectType], new Vector3(spawn.x, spawn.y, spawn.z), Quaternion.identity);
         *      go.transform.eulerAngles = new Vector3(0, spawn.Y_rot, 0);
         *      objects.Add(id, new Spawn() { id = id, type = GameObjectType.dragon, objectType = ObjectType.NPC, gameObject = go });
         *      NPC npc = go.GetComponent<NPC>();
         *      npc.id = id;
         *      npc.npc_type = spawn.npc_type;
         *      npc.aggro_range = spawn.aggro_range;
         *      GameServer.npcs.Add(id, npc);
         *  }
         * }*/
    }