Jump to content
This site uses cookies! Learn More

This site uses cookies!

armedunity.com uses cookies to improve user experience.

By continuing to use this site, you agree to allow us to store cookies on your computer.

Search the Community

Showing results for tags 'please'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • GENERAL
    • Introduce yourself
    • Discussions
    • Showcase
    • Need help?
    • Seeking team members?
    • Offtopic
  • RESOURCES
    • Example Projects
    • Scripts
    • Shaders
    • Unity Tutorials
    • FPS Kit Tutorials
    • 3D models
    • Animated 3D Models
    • Graphic design
    • Textures
    • Sounds
    • Other
  • SELL | REQUEST
    • Sell
    • Request
  • Mars' Modular Multiplayer Photon FPS Kit's Topics
  • Mars' Modular Multiplayer Photon FPS Kit's Reviews
  • Mars' Modular Multiplayer Photon FPS Kit's Updates
  • Mars' Modular Multiplayer Photon FPS Kit's Tutorials
  • Busy People's Introductions
  • Photon's Tutorials
  • Photon's Photon General
  • Photon's Showcase

Categories

  • Free Projects
  • Free Assets
  • Game Demos
  • Photon's Files

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


YouTube URL


Facebook URL


Twitter URL


IndieGoGo URL


Kickstarter URL


IndieDB URL


GreenLight URL


Location:


Interests

Found 16 results

  1. Hi guys how is it going? I know this is a long stretch but I am in need of some decent gun and arms rigs that are animated with the following animations: > Idle > Reload > Fire > Draw If anyone has some animated guns with arms on their PC or wherever, and are willing to share with the community for place holders only, NON COMMERCIAL use....then please help me. All the best, HairySeal
  2. Hello Guys, Iam a developer in Unity3D. Iam developing a car racing game. There will be the the of this game soon. Link to my Youtube videos: https://www.youtube.com/playlist?list=PL5f0H3dHKn9eTeaMcYLZZju_vgvFThHsR
  3. Hello everyone! I am having a bit of trouble with this Inventory System. My game is going fine but the only problem is that playing it would be pointless because the Inventory doesn't even save! If anyone knows how to implement saving please help! and I know the script is big sorry . Thanks SCRIPT : using UnityEngine; using System.Collections; using System.Collections.Generic; public class Player : MonoBehaviour { public Transform myTransform; public Transform myBody; public Transform myHips; public Transform mySpine; public Transform myCamera; public Transform mySpawnpoint; public List<Transform> myItems; private Multiplayer multiplayer; private Transform[] myArray; private CharacterMotor myCharMotor; public Texture2D[] CrossHairs; public Inventory myInventory; public GameObject[] AttackPrefabs; private ItemDatabase db; public float nextUseTime; public float myHealth; public const float MAX_HEALTH = 100; public float healthRegen; public float prevHealth; public bool hitted = false; public bool bleeding = false; public const float MAX_STATS = 100; public float myHunger; public float hungerTake; public float myThirst; public float thirstTake; public float arrowForce = 600.0f; private Texture2D texture_background; private Texture2D texture_hotbar; private Texture2D texture_inventory; private Texture2D texture_crafting; private Texture2D image; private Texture2D recipes; public bool isInventoryOpen = false; public float screenSizeMultiplier = 0.6f; public InventoryItem selectedItem; public Vector2 selectedPos; private Vector2 btnSize; private Vector2 mousePos; public GUISkin skin; void Start() { //Load myObjects myArray = new Transform[5]; myItems = new List<Transform>(); myTransform = transform; myArray[0] = myTransform; myBody = myTransform.FindChild("body"); myArray[1] = myBody; myHips = myBody.FindChild("Hips"); myArray[2] = myHips; mySpine = myHips.FindChild("Spine").FindChild("Spine1").FindChild("Spine2"); myArray[3] = mySpine; myCamera = mySpine.FindChild("MainCamera"); myArray[4] = myCamera; mySpawnpoint = myCamera.FindChild("Spawnpoint"); myCharMotor = myTransform.GetComponent<CharacterMotor>(); /***********************************/ //Select all items Transform itemHolder = mySpine.FindChild("RightShoulder").FindChild("RightArm").FindChild("RightForeArm").FindChild("RightHand").FindChild("Items"); foreach(Transform c in itemHolder) { myItems.Add(c); } EnableDisableItems(-1, false); //Disable all items. //Set default health options myHealth = 100; healthRegen = 1.3f; prevHealth = 100; //Set default hunger and thirst myHunger = 100; myThirst = 100; thirstTake = 0.1f; hungerTake = 0.01f; //Load Crosshairs CrossHairs = new Texture2D[3]; CrossHairs[0] = (Texture2D)Resources.Load("Textures/Crosshairs/Crosshair1"); //Default crosshair //Load GUI Textures texture_background = (Texture2D)Resources.Load("Textures/HUD/background"); texture_hotbar = (Texture2D)Resources.Load("Textures/HUD/hotbar"); texture_inventory = (Texture2D)Resources.Load("Textures/HUD/inventory"); texture_crafting = (Texture2D)Resources.Load("Textures/HUD/crafting"); recipes = (Texture2D)Resources.Load("Textures/HUD/recipes"); //Setup new Inventory myInventory = new Inventory(); selectedItem = InventoryItem.NULL; //Get db db = GameObject.Find("MPManager").GetComponent<ItemDatabase>(); multiplayer = GameObject.Find("MPManager").GetComponent<Multiplayer>(); btnSize = new Vector2(70.5f, 70.5f); if(GetComponent<NetworkView>().isMine) { InvokeRepeating("ThirstAndHungerController", 0, 1); } InvokeRepeating("UpdateSoundSettings", 0, 3); } void Update() { HealthController(); EquipmentController(); if(GetComponent<NetworkView>().isMine) { EquipmentUse(); } AnimationController(); } void UpdateSoundSettings() { GetComponent<AudioSource>().volume = multiplayer.GetComponent<AudioSource>().volume; } void HealthController() { if (myHealth < MAX_HEALTH) { if(bleeding) { myHealth -= healthRegen * Time.deltaTime; } else { myHealth += healthRegen * Time.deltaTime; } } if(myHunger > 80 && myThirst > 80) { healthRegen = 2.2f; } if (myHealth > MAX_HEALTH) { myHealth = MAX_HEALTH; } if (myHealth < 1 && GetComponent<NetworkView>().isMine) { GameObject.Find("SpawnManager").GetComponent<SpawnManager>().isDead = true; Network.RemoveRPCs(Network.player); GetComponent<NetworkView>().RPC("DestroySelf", RPCMode.All); } if(hitted) { GetComponent<NetworkView>().RPC("UpdateMyCurrentHealthEverywhere", RPCMode.Others, myHealth); hitted = false; } if (myHealth > 0 && GetComponent<NetworkView>().isMine) { if (myHealth != prevHealth) { GetComponent<NetworkView>().RPC("UpdateMyHealthEverywhere", RPCMode.AllBuffered, myHealth); } } } void ThirstAndHungerController() { if(myHunger > 0) { myHunger -= hungerTake; } else { bleeding = true; } /* if(myThirst > 0) { myThirst -= thirstTake; } else { bleeding = true; } * */ if(myThirst > 0 && myHunger > 0) { bleeding = false; } } void ReloadAmmo() { InventoryItem item = myInventory.getItemByPosition(myInventory.curItem); if(item.item.getType().Equals("Gun")) { int ammoLeft = 20 - item.status[2]; if(item.status[3] > ammoLeft) { item.status[2] += ammoLeft; item.status[3] -= ammoLeft; } else { item.status[2] += item.status[3]; item.status[3] = 0; } } } public void KickBack() { transform.position = Vector3.Lerp(transform.position, transform.position - (transform.forward - transform.up), 1); } void EquipmentUse() { if( Screen.lockCursor ) { if (Input.GetButton("Fire1") && Time.time > nextUseTime) { InventoryItem item = myInventory.getItemByPosition(myInventory.curItem); if(item.item.getType().Equals("Gun")) { //Check ammo if(item.status[2] < 1) { GetComponent<NetworkView>().RPC("NetworkAnimation", RPCMode.All, 3, "ReloadGun", true, 1f); Invoke("ReloadAmmo", 1f); return; } else { item.status[2]--; } } else if(item.item.getType().Equals("Consumable")) { if(item.item.getDescription().Contains("(Food)")) { if(myHunger < MAX_STATS) myHunger += item.item.getDamage(); } else if (item.item.getDescription().Contains("(Drink)")) { if (myHunger < MAX_STATS) myThirst += item.item.getDamage(); } myInventory.myItems[(int)myInventory.curItem.x, (int)myInventory.curItem.y] = InventoryItem.NULL; myInventory.RemoveFromHotbar(item); selectedItem = InventoryItem.NULL; selectedPos = new Vector2(29, 11); } else if (item.item.getType().Equals("Placeable")) { //myInventory.myItems[(int)myInventory.curItem.x, (int)myInventory.curItem.y] = InventoryItem.NULL; //myInventory.RemoveFromHotbar(item); //selectedItem = InventoryItem.NULL; //selectedPos = new Vector2(29, 11); } else if (item.item.getType().Equals("Bow")) { //Check ammo if (item.status[2] < 1) { Invoke("ReloadAmmo", 1f); return; } else { item.status[2]--; } } nextUseTime = Time.time + item.item.getUseDelay(); string animName = item.item.getUseAnimation(); GetComponent<NetworkView>().RPC("NetworkAnimation", RPCMode.All, 3, animName.Trim(), true, item.item.getAnimationSpeed()); GetComponent<NetworkView>().RPC( "SpawnAttack", RPCMode.All, mySpawnpoint.position, Quaternion.Euler(mySpawnpoint.eulerAngles.x + 90, mySpawnpoint.eulerAngles.y, 0), transform.name, item.item.ID); } if(Input.GetButtonDown("Reload")) { InventoryItem item = myInventory.getItemByPosition(myInventory.curItem); if (item.item.getType().Equals("Gun")) { GetComponent<NetworkView>().RPC("NetworkAnimation", RPCMode.All, 3, "ReloadGun", true, 1f); Invoke("ReloadAmmo", 1f); } } if (Input.GetButton("Fire2")) { myCamera.GetComponent<Camera>().fieldOfView = Mathf.Lerp(myCamera.GetComponent<Camera>().fieldOfView, 40f, 2f * Time.deltaTime); } else { myCamera.GetComponent<Camera>().fieldOfView = Mathf.Lerp(myCamera.GetComponent<Camera>().fieldOfView, 60f, 2f * Time.deltaTime); } } } public void DeletePlaceable() { InventoryItem item = myInventory.getItemByPosition(myInventory.curItem); myInventory.myItems[(int)myInventory.curItem.x, (int)myInventory.curItem.y] = InventoryItem.NULL; myInventory.RemoveFromHotbar(item); selectedItem = InventoryItem.NULL; selectedPos = new Vector2(29, 11); } void EquipmentController() { InventoryItem curItem = myInventory.getItemByPosition(myInventory.curItem); int goID; if(curItem.Equals(InventoryItem.NULL)) { goID = 0; } else { goID = myInventory.getItemByPosition(myInventory.curItem).item.ID; } if (myItems[goID] != null) { EnableDisableItems(-1, false); EnableDisableItems(goID, true); } else { EnableDisableItems(-1, false); myInventory.curItem = new Vector2(0,0); } if(GetComponent<NetworkView>().isMine) { if (Input.GetMouseButtonDown(1) && !selectedItem.Equals(InventoryItem.NULL)) { selectedItem = InventoryItem.NULL; } if (Input.GetKeyDown(KeyCode.Alpha1)) { myInventory.curItem = myInventory.myHotbar[0]; GetComponent<NetworkView>().RPC("NetworkAnimation", RPCMode.All, 3, "SwitchItem", true, 1.0f); } if (Input.GetKeyDown(KeyCode.Alpha2)) { myInventory.curItem = myInventory.myHotbar[1]; GetComponent<NetworkView>().RPC("NetworkAnimation", RPCMode.All, 3, "SwitchItem", true, 1.0f); } if (Input.GetKeyDown(KeyCode.Alpha3)) { myInventory.curItem = myInventory.myHotbar[2]; GetComponent<NetworkView>().RPC("NetworkAnimation", RPCMode.All, 3, "SwitchItem", true, 1.0f); } if (Input.GetKeyDown(KeyCode.Alpha4)) { myInventory.curItem = myInventory.myHotbar[3]; GetComponent<NetworkView>().RPC("NetworkAnimation", RPCMode.All, 3, "SwitchItem", true, 1.0f); } if (Input.GetKeyDown(KeyCode.Alpha5)) { myInventory.curItem = myInventory.myHotbar[4]; GetComponent<NetworkView>().RPC("NetworkAnimation", RPCMode.All, 3, "SwitchItem", true, 1.0f); } if(Input.GetButtonDown("Friendly")) { GetComponent<NetworkView>().RPC("NetworkAnimation", RPCMode.All, 3, "Friendly", true, 1.0f); } if(Input.GetButtonDown("Inventory")) { isInventoryOpen = !isInventoryOpen; multiplayer.EnableDisablePlayer(!isInventoryOpen); if (isInventoryOpen) multiplayer.gameState = Multiplayer.GameState.INVENTORY; else multiplayer.gameState = Multiplayer.GameState.PLAYING; } GetComponent<NetworkView>().RPC("SendCurrentItem", RPCMode.Others, (int)myInventory.curItem.x, (int)myInventory.curItem.y); } } void EnableDisableItems(int index, bool enable) { if(index == -1) { for (int i = 0; i < myItems.Count; i++) { myItems[i].gameObject.SetActive(enable); } } else { myItems[index].gameObject.SetActive(enable); } } int GetItemIndex(string GameObjectName) { for (int i = 0; i < myItems.Count; i++) { if (myItems[i].gameObject.name.Equals(GameObjectName)) return i; } return -1; } void OnGUI() { if(GetComponent<NetworkView>().isMine) { mousePos = new Vector2 (Input.mousePosition.x, -Input.mousePosition.y + Screen.height); GUI.skin = skin; if(multiplayer.gameState.Equals(Multiplayer.GameState.PLAYING) || multiplayer.gameState.Equals(Multiplayer.GameState.INVENTORY)) { //Draw Crosshair GUI.DrawTexture(new Rect(Screen.width / 2 - CrossHairs[0].width / 2, Screen.height / 2 - CrossHairs[0].height / 2, CrossHairs[0].width, CrossHairs[0].height), CrossHairs[0]); //Draw Hotbar and Inventory GUIController(); } if (Input.GetButton("Recipes")) { GUI.DrawTexture(new Rect(0, 0, Screen.width, Screen.height), recipes, ScaleMode.StretchToFill); } } } void GUIController() { if(isInventoryOpen) { //Draw Background GUI.DrawTexture(new Rect(0, 0, Screen.width, Screen.height), texture_background, ScaleMode.StretchToFill); //Draw Crafting float craft_w = texture_crafting.width * screenSizeMultiplier; float craft_h = texture_crafting.height * screenSizeMultiplier; Rect craftRect = new Rect(Screen.width / 2 - craft_w / 2, 0, craft_w, craft_h); GUI.DrawTexture(craftRect, texture_crafting); int btnsToShow = 1; for (int i = 0; i < myInventory.craftList.Count; i++) { if(!myInventory.craftList[i].Equals(InventoryItem.NULL)) { btnsToShow++; } } if(GUI.Button(new Rect(Screen.width - 100, 10, 100, 50), "Clear")) { myInventory.ClearCraftList(); } if (btnsToShow > 4) { btnsToShow = 4; } if(btnsToShow > 1) { //Lets see the recipe so far InventoryItem itemToCraft = db.getItemForRecipe(myInventory.craftList); if(!itemToCraft.Equals(InventoryItem.NULL)) { Vector2 startPos = new Vector2(craftRect.x + 12f * screenSizeMultiplier, craftRect.y + 60f * screenSizeMultiplier); Vector2 btnPos = startPos + new Vector2(btnSize.x * screenSizeMultiplier * 5 + (12f * screenSizeMultiplier * 5), 0); Texture2D image = (Texture2D)Resources.Load("Textures/Items/" + itemToCraft.item.ID); if (GUI.Button(new Rect(btnPos.x, btnPos.y, (btnSize.x) * screenSizeMultiplier, (btnSize.y - 10f) * screenSizeMultiplier), image)) { RemoveItemNetwork(db.getRecipeToRemove(itemToCraft, myInventory.craftList)); //Take the used resources myInventory.ClearCraftList(); //Clear craft list if(AddItemNetwork(itemToCraft)) { Debug.Log("Added Item"); } itemToCraft = InventoryItem.NULL; } } } for (int i = 0; i < btnsToShow; i++) { Vector2 startPos = new Vector2(craftRect.x + 12f * screenSizeMultiplier, craftRect.y + 60f * screenSizeMultiplier); Vector2 btnPos = startPos + new Vector2(btnSize.x * screenSizeMultiplier * i + (12f * screenSizeMultiplier * i), 0); if(myInventory.craftList[i].Equals(InventoryItem.NULL)) { if (GUI.Button(new Rect(btnPos.x, btnPos.y, (btnSize.x) * screenSizeMultiplier, (btnSize.y - 10f) * screenSizeMultiplier), "")) { if (!selectedItem.Equals(InventoryItem.NULL)) { myInventory.craftList[i] = selectedItem ; selectedItem = InventoryItem.NULL; selectedPos = new Vector2(29, 11); } } } else { Texture2D image = (Texture2D)Resources.Load("Textures/Items/" + myInventory.craftList[i].item.ID); GUI.DrawTexture(new Rect(btnPos.x, btnPos.y, (btnSize.x) * screenSizeMultiplier, (btnSize.y - 10f) * screenSizeMultiplier), image); } } //Draw Inventory float inv_w = texture_inventory.width * screenSizeMultiplier; float inv_h = texture_inventory.height * screenSizeMultiplier; Rect windowRect = new Rect(Screen.width / 2 - inv_w / 2, Screen.height / 2 - inv_h / 2, inv_w, inv_h); GUI.DrawTexture(windowRect, texture_inventory); //Drop Item if(!selectedItem.Equals(InventoryItem.NULL) && !selectedItem.item.getType().Equals("Placeable")) { if(GUI.Button(new Rect(10, 10, 100, 50), "Drop")) { if(selectedItem.status[0] > 1) //If stackable { selectedItem.status[0]--; } else { myInventory.myItems[(int)selectedPos.x, (int)selectedPos.y] = InventoryItem.NULL; myInventory.RemoveFromHotbar(selectedItem); } Network.Instantiate((Object)Resources.Load("Prefabs/Drop/" + selectedItem.item.Name), myTransform.position, Quaternion.identity, 2); selectedItem = InventoryItem.NULL; selectedPos = new Vector2(29, 11); } } //Draw Inventory Items for (int y = 0; y < myInventory.myItems.GetLength(1); y++) { for (int x = 0; x < myInventory.myItems.GetLength(0); x++) { Vector2 startPos = new Vector2(windowRect.x + 12f * screenSizeMultiplier, windowRect.y + 75f * screenSizeMultiplier); Vector2 pos = new Vector2(x, y); Vector2 btnPos = startPos + new Vector2(btnSize.x * screenSizeMultiplier * x + (12f * screenSizeMultiplier * x), btnSize.y * screenSizeMultiplier * y + (12f * screenSizeMultiplier * y)); if(myInventory.unlocked[x,y]) { if(myInventory.myItems[x,y].Equals(InventoryItem.NULL)) { //Trocar com o fists if (GUI.Button(new Rect(btnPos.x, btnPos.y, btnSize.x * screenSizeMultiplier, btnSize.y * screenSizeMultiplier), "")) { if(!selectedItem.Equals(InventoryItem.NULL)) { if (!selectedPos.Equals(new Vector2(29, 11))) myInventory.UpdateHotbar(selectedPos, new Vector2(x,y)); myInventory.myItems[x, y] = selectedItem; selectedItem = InventoryItem.NULL; if(!selectedPos.Equals(new Vector2(29, 11))) myInventory.myItems[(int)selectedPos.x, (int)selectedPos.y] = InventoryItem.NULL; selectedPos = new Vector2(29, 11); } } } else { InventoryItem item = myInventory.myItems[x, y]; image = (Texture2D)Resources.Load("Textures/Items/" + item.item.ID); if(!selectedItem.Equals(InventoryItem.NULL)) { //We have a selected item, and we want to replace with other item. if (GUI.Button(new Rect(btnPos.x, btnPos.y, btnSize.x * screenSizeMultiplier, btnSize.y * screenSizeMultiplier), image)) { myInventory.myItems[(int)selectedPos.x, (int)selectedPos.y] = item; myInventory.myItems[x, y] = selectedItem; selectedItem = InventoryItem.NULL; selectedPos = new Vector2(29, 11); } if (item.status[1] != 0) //If its stackable { GUI.Label(new Rect(btnPos.x + (btnSize.x * screenSizeMultiplier / 2), btnPos.y + btnSize.y * screenSizeMultiplier - 20, 30, 20), "x" + item.status[0].ToString()); } } else { //We want to choose an item if (GUI.Button(new Rect(btnPos.x, btnPos.y, btnSize.x * screenSizeMultiplier, btnSize.y * screenSizeMultiplier), image)) { selectedItem = item; selectedPos = new Vector2(x, y); } if (item.status[1] != 0) //If its stackable { GUI.Label(new Rect(btnPos.x + (btnSize.x * screenSizeMultiplier / 2), btnPos.y + btnSize.y * screenSizeMultiplier - 20, 30, 20), "x" + item.status[0].ToString()); } } } } } } //Draw Hotbar with buttons float hotbar_w = texture_hotbar.width * screenSizeMultiplier; float hotbar_h = texture_hotbar.height * screenSizeMultiplier; GUI.DrawTexture(new Rect( Screen.width / 2 - hotbar_w / 2, Screen.height - hotbar_h, hotbar_w, hotbar_h), texture_hotbar); for(int i = 0; i < myInventory.myHotbar.Length; i++) { Vector2 hotbarItem = myInventory.myHotbar[i]; float img_w = 87 * screenSizeMultiplier; float img_h = 87 * screenSizeMultiplier; float base_x = Screen.width / 2 - hotbar_w / 2 + (12 * screenSizeMultiplier) + (img_w * i) + (12 * screenSizeMultiplier * i); float base_y = Screen.height - hotbar_h + 12; InventoryItem item = myInventory.getItemByPosition(myInventory.myHotbar[i]); Texture2D image = (Texture2D)Resources.Load("Textures/Items/" + item.item.ID); if(!hotbarItem.Equals(new Vector2(29, 11))) { if(item.item.ID != 0) { if (GUI.Button(new Rect(base_x, base_y, img_w, img_h), image)) { if(!selectedItem.Equals(InventoryItem.NULL)) { myInventory.myHotbar[i] = myInventory.getItemPosition(item.item); selectedItem = InventoryItem.NULL; selectedPos = new Vector2(29, 11); } else { if(Event.current.button == 1) { myInventory.myHotbar[i] = new Vector2(29, 11); } } } } } else { if (GUI.Button(new Rect(base_x, base_y, img_w, img_h), image)) { if(!selectedItem.Equals(InventoryItem.NULL)) { myInventory.myHotbar[i] = myInventory.getItemPosition(selectedItem.item); selectedItem = InventoryItem.NULL; selectedPos = new Vector2(29, 11); } } } } if(!selectedItem.Equals(InventoryItem.NULL)) { Texture2D image = (Texture2D)Resources.Load("Textures/Items/" + selectedItem.item.ID); GUI.Box(new Rect(mousePos.x, mousePos.y, btnSize.x, btnSize.y), image); } //Debug /* for (int y = 0; y < myInventory.myItems.GetLength(1); y++) { for (int x = 0; x < myInventory.myItems.GetLength(0); x++) { GUI.Label(new Rect(0 + x * 100, 0 + y * 20, 100, 20), myInventory.myItems[x, y].item.Name); } } for(int i = 0; i < myInventory.myHotbar.Length; i++) { GUI.Label(new Rect(0 + i * 100, 150, 100, 20), myInventory.myHotbar[i].ToString()); } GUI.Label(new Rect(0, 170, 500, 20), selectedItem.item.Name + " " + selectedPos.ToString()); * */ } else { //Draw Hotbar float hotbar_w = texture_hotbar.width * screenSizeMultiplier; float hotbar_h = texture_hotbar.height * screenSizeMultiplier; GUI.DrawTexture(new Rect( Screen.width / 2 - hotbar_w / 2, Screen.height - hotbar_h, hotbar_w, hotbar_h), texture_hotbar); //Draw Hotbar Items for (int i = 0; i < myInventory.myHotbar.Length; i++) { float img_w = 87 * screenSizeMultiplier; float img_h = 87 * screenSizeMultiplier; float base_x = Screen.width / 2 - hotbar_w / 2 + (12 * screenSizeMultiplier) + (img_w * i) + (12 * screenSizeMultiplier * i); float base_y = Screen.height - hotbar_h + 12; InventoryItem item = myInventory.getItemByPosition(myInventory.myHotbar[i]); //Item in the hotbar Texture2D image = (Texture2D)Resources.Load("Textures/Items/" + item.item.ID); GUI.DrawTexture(new Rect(base_x, base_y, img_w, img_h), image); } } } void AnimationController() { //Walk Animation if(myCharMotor.movement.velocity.magnitude >= 2) { if(!myHips.GetComponent<Animation>().isPlaying) { GetComponent<NetworkView>().RPC("NetworkAnimation", RPCMode.All, 2, "Walk", true, 1.0f); } } //Weapons if(!mySpine.GetComponent<Animation>().isPlaying) { if (myInventory.getItemByPosition(myInventory.curItem).Equals(InventoryItem.NULL)) { GetComponent<NetworkView>().RPC("NetworkAnimation", RPCMode.All, 3, "IdleFists", true, 1.0f); } else { if (myInventory.getItemByPosition(myInventory.curItem).item.Type.Equals("MeleeDual")) //Dual Wield { GetComponent<NetworkView>().RPC("NetworkAnimation", RPCMode.All, 3, "IdleDualHands", true, 1.0f); } else if (myInventory.getItemByPosition(myInventory.curItem).item.Type.Equals("MeleeSpear")) //Spear Wield { GetComponent<NetworkView>().RPC("NetworkAnimation", RPCMode.All, 3, "SpearIdle", true, 1.0f); } else if (myInventory.getItemByPosition(myInventory.curItem).item.Type.Equals("MeleeOne")) //One hand weapon { GetComponent<NetworkView>().RPC("NetworkAnimation", RPCMode.All, 3, "OneHandIdle", true, 1.0f); } else if (myInventory.getItemByPosition(myInventory.curItem).item.Type.Equals("Item")) //Item Idle { GetComponent<NetworkView>().RPC("NetworkAnimation", RPCMode.All, 3, "IdleDualHands", true, 1.0f); } else if (myInventory.getItemByPosition(myInventory.curItem).item.Type.Equals("Gun")) //Gun Idle { GetComponent<NetworkView>().RPC("NetworkAnimation", RPCMode.All, 3, "IdleGunDualHands", true, 1.0f); } else if (myInventory.getItemByPosition(myInventory.curItem).item.Type.Equals("Bow")) //Bow Idle { GetComponent<NetworkView>().RPC("NetworkAnimation", RPCMode.All, 3, "IdleDualHands", true, 1.0f); } else if (myInventory.getItemByPosition(myInventory.curItem).item.Type.Equals("Consumable")) //Bow Idle { GetComponent<NetworkView>().RPC("NetworkAnimation", RPCMode.All, 3, "IdleDualHands", true, 1.0f); } else if (myInventory.getItemByPosition(myInventory.curItem).item.Type.Equals("Placeable")) //Bow Idle { GetComponent<NetworkView>().RPC("NetworkAnimation", RPCMode.All, 3, "IdleDualHands", true, 1.0f); } else { GetComponent<NetworkView>().RPC("NetworkAnimation", RPCMode.All, 3, "IdleFists", true, 1.0f); } } } } void SpawnSound(Vector3 pos, string clipName) { GameObject go = (GameObject)Resources.Load("Prefabs/General/AudioSpawner"); go = Instantiate(go, pos, Quaternion.identity) as GameObject; go.GetComponent<AudioSource>().PlayOneShot((AudioClip)Resources.Load("Sounds/" + clipName)); } IEnumerator InstantiateAttack(Vector3 pos, Quaternion rot, string owner, int itemID, float delay) { yield return new WaitForSeconds(delay); SpawnSound(transform.position, db.Items[itemID].getAudioName()); if (!pos.Equals(mySpawnpoint.position)) { pos = mySpawnpoint.position; } if(!rot.Equals(Quaternion.Euler(mySpawnpoint.eulerAngles.x + 90, mySpawnpoint.eulerAngles.y, 0))) { rot = Quaternion.Euler(mySpawnpoint.eulerAngles.x + 90, mySpawnpoint.eulerAngles.y, 0); } GameObject go = Instantiate(AttackPrefabs[db.Items[itemID].getPrefabAttack()], pos, rot) as GameObject; MeleeAttack m = go.GetComponent<MeleeAttack>(); if(m != null) { m.owner = owner; m.weaponID = itemID; } else { go.GetComponent<Arrow>().owner = owner; go.GetComponent<Arrow>().weaponID = itemID; go.GetComponent<Rigidbody>().AddForce(mySpawnpoint.forward * arrowForce); } } public bool AddItemNetwork(InventoryItem item) { Vector2 slot = myInventory.getNextAvailableSlot(); if(myInventory.AddItem(item)) { GetComponent<NetworkView>().RPC("AddItemOverNetwork", RPCMode.OthersBuffered, item.item.ID, (int)slot.x, (int)slot.y); return true; } else { return false; } } public bool RemoveItemNetwork(InventoryItem item, int qtd) { Vector2 slot = myInventory.getItemPosition(item.item); if (myInventory.RemoveItem(item, qtd)) { GetComponent<NetworkView>().RPC("RemoveItemOverNetwork", RPCMode.OthersBuffered, item.item.ID, qtd); return true; } else { return false; } } public bool RemoveItemNetwork(List<InventoryItem> item) { for(int x = 0; x < item.Count; x++) { Vector2 slot = myInventory.getItemPosition(item[x].item); if (myInventory.RemoveItem(item[x], item[x].status[0])) { GetComponent<NetworkView>().RPC("RemoveItemOverNetwork", RPCMode.OthersBuffered, item[x].item.ID, item[x].status[0]); } } return true; } /* * RPC's */ [RPC] void SpawnAttack(Vector3 pos, Quaternion rot, string owner, int itemID) { StartCoroutine( InstantiateAttack( pos, rot, owner, itemID, db.Items[itemID].getAttackSpawnDelay() )); } [RPC] void NetworkAnimation(int trans, string anim, bool cf, float AnimSpeed) { if(myArray[trans] != null) myArray[trans].GetComponent<Animation>()[anim].speed = AnimSpeed; if (cf) //Crossfade? { myArray[trans].GetComponent<Animation>().CrossFade(anim); } else { myArray[trans].GetComponent<Animation>().Play(anim); } } [RPC] void SendCurrentItem(int x, int y) { myInventory.curItem = new Vector2(x, y); } [RPC] void DestroySelf() { Destroy(gameObject); } [RPC] void UpdateMyHealthEverywhere( float hp) { prevHealth = hp; } [RPC] void UpdateMyCurrentHealthEverywhere(float hP) { myHealth = hP; } [RPC] public void AddItemOverNetwork(int itemID, int x, int y) { multiplayer.GetComponent<Console>().Write("AddItemOverNetwork Called in player " + gameObject.name); Item i = GameObject.Find("MPManager").GetComponent<ItemDatabase>().getItemByID(itemID); myInventory.myItems[x, y] = new InventoryItem(i, InventoryItem.DefaultStatus(false, 0, 1)); multiplayer.GetComponent<Console>().Write("Item " + i.ToString() + " added to " + new Vector2(x,y).ToString() + " on player " + gameObject.name); } [RPC] public void RemoveItemOverNetwork(int itemID, int qtd) { multiplayer.GetComponent<Console>().Write("RemoveItemOverNetwork Called in player " + gameObject.name); Item i = GameObject.Find("MPManager").GetComponent<ItemDatabase>().getItemByID(itemID); InventoryItem itemToDelete = new InventoryItem(i, InventoryItem.DefaultStatus(false, 1, 1)); if (myInventory.RemoveItem(itemToDelete, qtd)) { multiplayer.GetComponent<Console>().Write("Item " + i.ToString() + " removed on player " + gameObject.name); } else { multiplayer.GetComponent<Console>().Error("Item couldn't be removed!"); } } } public class Inventory { public Vector2 curItem; public InventoryItem[,] myItems; public bool[,] unlocked; public Vector2[] myHotbar; public int maxItems; public List<InventoryItem> craftList; public Inventory() { curItem = new Vector2(29, 11); myItems = new InventoryItem[6, 5]; unlocked = new bool[6, 5]; craftList = new List<InventoryItem>(); myHotbar = new Vector2[5]; maxItems = 10; ItemDatabase db = GameObject.Find("MPManager").GetComponent<ItemDatabase>(); setupArray(); OpenSlots(12); AddItem(new InventoryItem(db.getItemByName("WoodAxe"), InventoryItem.DefaultStatus(false, 0, 1))); } public void UpdateHotbar(Vector2 old, Vector2 newpos) { for (int i = 0; i < myHotbar.Length; i++) { if (myHotbar[i].Equals(old)) myHotbar[i] = newpos; } } public void ClearCraftList() { for (int i = 0; i < craftList.Count; i++) { craftList[i] = InventoryItem.NULL; } } public void setupArray() { for (int i = 0; i < myHotbar.Length; i++) { myHotbar[i] = new Vector2(29, 11); } for (int y = 0; y < myItems.GetLength(1); y++) { for (int x = 0; x < myItems.GetLength(0); x++) { myItems[x, y] = InventoryItem.NULL; } } for (int i = 0; i < 4; i++) { craftList.Add(InventoryItem.NULL); } } public InventoryItem getItemByPosition(Vector2 pos) { if (isValid(pos)) { if (!myItems[(int)pos.x, (int)pos.y].Equals(InventoryItem.NULL)) { return myItems[(int)pos.x, (int)pos.y]; } else { return InventoryItem.NULL; } } return InventoryItem.NULL; } public Vector2 getItemPosition(Item item) { for (int y = 0; y < myItems.GetLength(1); y++) { for (int x = 0; x < myItems.GetLength(0); x++) { if (myItems[x, y] != null) { if (myItems[x, y].item.Equals(item)) { return new Vector2(x, y); } } } } return new Vector2(29, 11); } public Vector2 getNextAvailableSlot() { for (int y = 0; y < unlocked.GetLength(1); y++) { for (int x = 0; x < unlocked.GetLength(0); x++) { if (myItems[x, y].Equals(InventoryItem.NULL) && unlocked[x, y]) { return new Vector2(x, y); } } } return new Vector2(29, 11); } public Vector2 getNextSlot() { for (int y = 0; y < myItems.GetLength(1); y++) { for (int x = 0; x < myItems.GetLength(0); x++) { if (unlocked[x, y] == false) { return new Vector2(x, y); } } } return new Vector2(29, 11); } public static bool isValid(Vector2 validate) { return !validate.Equals(new Vector2(29, 11)); } public bool AddItem(InventoryItem newItem, Vector2 slot) { if (isValid(slot)) { if (newItem.status[1] != 0) //Item is stackable { if (isValid(getItemPosition(newItem.item)) && getItemByPosition(getItemPosition(newItem.item)).status[0] < 10) //Already exists, lets add to the stack. { int pos_x = (int)getItemPosition(newItem.item).x; int pos_y = (int)getItemPosition(newItem.item).y; myItems[pos_x, pos_y].status[0]++; //Increase the amount of the item return true; //Success on adding the item. } else //Item doesn't exist yet { myItems[(int)slot.x, (int)slot.y] = newItem; return true; } } else { //Item is not stackable, so add it to a new position myItems[(int)slot.x, (int)slot.y] = newItem; return true; } } return false; } public void OpenSlots(int amount) { Vector2 start = getNextSlot(); int done = 0; for (int y = (int)start.y; y < myItems.GetLength(1); y++) { for (int x = (int)start.x; x < myItems.GetLength(0); x++) { if (done < amount) { unlocked[x, y] = true; done++; } } } } public bool AddItem(InventoryItem item) { Vector2 position = getNextAvailableSlot(); if (isValid(position)) { if (AddItem(item, position)) { return true; } else { return false; } } return false; } public bool RemoveItem(InventoryItem item, int qtd) { Vector2 position = getItemPosition(item.item); if(isValid(position)) { InventoryItem i = myItems[(int)position.x, (int)position.y]; int itemQtd = i.status[0]; if(itemQtd - qtd < 1) { //Remover o item todo myItems[(int)position.x, (int)position.y] = InventoryItem.NULL; } else { i.status[0] -= qtd; } return true; } else { return false; } } public bool RemoveItem(List<InventoryItem> item) { for(int x = 0; x < item.Count; x++) { Vector2 position = getItemPosition(item[x].item); if (isValid(position)) { InventoryItem i = myItems[(int)position.x, (int)position.y]; int itemQtd = i.status[0]; if (itemQtd - item[x].status[0] < 1) { //Remover o item todo myItems[(int)position.x, (int)position.y] = InventoryItem.NULL; } else { i.status[0] -= item[x].status[0]; } } } return true; } public void RemoveFromHotbar(InventoryItem item) { Vector2 posToRemove = getItemPosition(item.item); for (int i = 0; i < myHotbar.Length; i++) { if (myHotbar[i].Equals(posToRemove)) { myHotbar[i] = new Vector2(29, 11); } } } } public class InventoryItem { public Item item; public List<int> status; public InventoryItem(Item i, List<int> s) { this.item = i; this.status = s; } public static List<int> DefaultStatus(bool stackable, int stackAmmount, int quantity) { //Status Configuration: //Quantity | Stackable | Ammo | Extra Ammo List<int> s = new List<int>(); if(stackable) { s.Add(quantity); //First is quantity s.Add(stackAmmount); //Second is stackable size } else { s.Add(quantity); //First Quantity s.Add(0); } s.Add(20); s.Add(40); return s; } public override string ToString() { if (item == null) return "Inv item with null item"; else return "InvItem | " + item.ToString(); } public static InventoryItem NULL = new InventoryItem(GameObject.Find("MPManager").GetComponent<ItemDatabase>().getItemByName("Fists"), null); }
  4. Looking for short paid Projects,no game end share please, I can create Props and weapons Contact me - kshubham331@gmail.com Skype - kshubham331 or PM me Few Screenshots
  5. Hi everybody. When I run my Unity 3D project (K2S), I get this error message... Does anyone know where it comes from, and how to fix ?
  6. https://dl.dropboxusercontent.com/u/266786110/C-47A-Skytrain-N1944A-fsx1.jpg (Picture I went off of) Hey guys. so a few days ago I made a ww2 plane model. And I stupidly pressed Ctrl Z while I was in Object mode and it deleted everything I worked on - _ - so I raged, Anyway I was wondering if anyone could make me a quick model of this? The player needs to go into the plane so it needs to be hollow inside. Thanks in advance -Stuart
  7. Hey guys. I was wondering how I would achieve a water droplet effect on the main camera? I followed a few tutorials but they weren't really what I was looking for. I a video that Unistorm had one. But I don't see it anywhere in the Unistorm file. I also read that you could do this with a plane that is up close to the main camera? Thanks -Stuart
  8. var gameName:String = ""; private var btnX:float; private var btnY:float; private var btnW:float; private var btnH:float; function Start(){ btnX = Screen.width * 0.1; btnY = Screen.width * 0.1; btnW = Screen.width * 0.2; btnH = Screen.width * 0.2; } function startServer() Network.InitializeServer(32, 25001, !Network.HavePublicAddress); MasterServer.RegisterHost(gameName, "My Game", 'This is My Game "); } //Messages function OnServerInitialized(){ Debug.Log("Server Initialized!"); } function OnMasterServerEvent(mse:MasterServerEvent){ if(mse == MasterServer.RegistrationSucceeded){ Debug.Log("Registerd Server"); } } function OnGUI(){ if(GUI.Button(Rect(btnX, btnY, btnW, btnH), "Start Server")){ Debug.Log("Starting Server"); startServer(); } if(GUI.Button(Rect(btnX, btnY * 1.2 + btnH, btnW, btnH), "Refresh Host")){ Debug.Log("Refreshing"); } } Hey guys. So ive been following a tutorial on adding multiplayer. Ive been ok at fixing the errors (Just forgot to add a ; or a { ) but this one I can't figure out D: it says its on line 16,5 and line 17,72 which is the Network.InitializeServer and the line below it ( I think ) Anyhelp would be awesome! Thanks -Stuart
  9. Clunk

    Camera Move?

    Hey guys. I was wondering how I would make the camera move from position to position to position. And at each position it stops for a few seconds. Kind of like DaBoss's Main menu. But it would auto move. If anyone could help me out and tell me how I would do it. Or link me with a tutorial on how, that would be awesome thanks -Stuart
  10. Hey guys! Im trying to make a radio like object in my game. I want it so when I walk up to my "Radio" Object I can press "E" It will play the song. And when I press "E" Again it stops playing the song. I looked it up on Google but couldn't find much on how to do it. Im not the best Coder. So I don't know what to do. I would appreciate it if you guys could help me. Or send me a link to a video or a web page on how to do it. Thanks -Stuart
  11. Guest

    Networking Multiplayer

    Heyy Guys, Just wounding.. I've been looking around for a while.. Now, I'm looking on helps of websites for this, but it doesn't answer my Question.. How would you go about doing a server like Minecraft, Valve Games, Dedicated Servers? Does anyone, know how to go about this? Cheers! Caleb Butterfield!
  12. I want to make my game not completely black & white, but just slightly. I dont want to take ALL of the color away. Any way I can do this? I have Color 3 from the Asset Store but it has no B&W effect, so I tried taking one of the Lut textures and making it black and white in Gimp, but got this mess:
  13. Hey all I have created a model in cinema 4D... I can export to whatever, But i need to texture it.. I have like 0 skill in it at all I have tried but failed. I want the textures to be dark "Post Apocalyptic" 'ish scratches and what not... I can't UV MAP so i can't give you the texture maps so the only logical thing to do is send you the model... Hopefully not to be stolen if you think you can help me let me know Here is a pic of the model Thanks for your time!
  14. Hi people i was just wondering if anyone knew how to make intros and cenimatics in unity pro thanks. I was also wondering how to import video? Thanks guys, P.S. Check out my website here http://magicpotatoproductions.weebly.com/
  15. I have a script called weapon manager which has a variable called currentWeap. My FPSWalker script has a variable called currenWeapon. I want currentWeapon in FPSWalker to = currentWeap in weapon manager. How would I go about doing this? Sorry if this is hard to understand, I'm having trouble putting this in words. It's like 2:00 AM here
  16. skatersfun

    Mouse Cursor

    Can you change the mouse cursor inside the game like on black ops and cod games to a custom cursor
×
×
  • Create New...