Inheritance: MonoBehaviour
示例#1
0
    // Update is called once per frame
    void Update()
    {
        if ((p1 == null) || (tutorialUI == null))
        {
            p1 = GameObject.FindGameObjectWithTag("Player").GetComponent <Player>();
            if (!p1.sandBoxMode)
            {
                tutorialUI    = GameObject.FindGameObjectWithTag("TutorialUI");
                botBackground = tutorialUI.transform.GetChild(0).gameObject;
                topBackground = tutorialUI.transform.GetChild(1).gameObject;
            }
        }
        if (!p1.sandBoxMode)
        {
            if (p1.inHUBWorld && (shop == null))
            {
                shop = GameObject.FindGameObjectWithTag("ShopMenuUI").GetComponent <ShopScript>();
            }
            shopIsActive = (shop == null) ? false : true;
            Tutorials();

            if (numOfCompletedTutorials == numOfTutorials)
            {
                this.enabled = false;
            }
        }
    }
示例#2
0
 void Start()
 {
     _shop = GameObject.FindGameObjectWithTag("Shop").GetComponent <ShopScript>();
     ChangeCount(1);
     _nameText.text = _item.Name;
     _currency.text = "x " + GameObject.FindGameObjectWithTag("Persistent").GetComponent <PersistentScript>()._gold;
 }
示例#3
0
    public int[] itemInventory_;        //0 : none, 1: buy, 2: buy and used

    private void Awake()
    {
        playerScript_ = GameObject.Find("Player").GetComponent <PlayerScript>();
        worldScript_  = gameObject.GetComponent <WorldScript>();
        stageLoader_  = gameObject.GetComponent <StageLoader>();
        shopScript_   = GameObject.Find("ShopUI").GetComponent <ShopScript>();

        TimeText_     = GameObject.Find("UI").transform.Find("Time").GetComponent <Text>();
        FishText_     = GameObject.Find("UI").transform.Find("Fish").GetComponent <Text>();
        DistanceText_ = GameObject.Find("UI").transform.Find("Distance").GetComponent <Text>();
        SpeedText_    = GameObject.Find("UI").transform.Find("Speed").GetComponent <Text>();

        // create object instanace
        fishPool_      = new GameObject[FISH_INSCREEN_MAX_NUM];
        largeHolePool_ = new GameObject[LARGE_HOLE_INSCREEN_MAX_NUM];
        fishHolePool_  = new GameObject[FISH_HOLE_INSCREEN_MAX_NUM];
        crackPool_     = new GameObject[CRACK_INSCREEN_MAX_NUM];
        rockPool_      = new GameObject[ROCK_INSCREEN_MAX_NUM];
        shopPool_      = new GameObject[SHOP_INSCREEN_MAX_NUM];

        DebugText_ = GameObject.Find("UI").transform.Find("Debug").GetComponent <Text>();

        itemInventory_ = new int[(int)Constant.ItemDef.TOTALITEMCOUNT];
        for (int i = 0; i < (int)Constant.ItemDef.TOTALITEMCOUNT; ++i)
        {
            itemInventory_[i] = 0;
        }
        //currentStage_ = 1;
    }
示例#4
0
 void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
 }
示例#5
0
 void Awake()
 {
     Items = new Stack <Item>();// instantiates items upon awake
     if (GameObject.FindObjectOfType <ShopScript>())
     {
         shop = GameObject.FindObjectOfType <ShopScript>().GetComponent <ShopScript>();
     }
     // gets shop script from shop in scene if there
 }
 void Awake()
 {
     playerShop    = GetComponent <ShopScript>();
     spellManager  = GetComponent <SpellManager>();
     _playerHealth = GetComponent <PlayerHealth_NET>();
     _rigidbody    = GetComponent <Rigidbody>();
     anim          = GetComponent <Animator>();
     m_PhotonView  = GetComponent <PhotonView>();
 }
示例#7
0
 // Start is called before the first frame update
 void Start()
 {
     bulletSpawner  = FindObjectOfType <BulletSpawner>();
     enemySpawner   = FindObjectOfType <EnemySpawner>();
     soundManager   = FindObjectOfType <SoundManager>();
     shop           = FindObjectOfType <ShopScript>();
     scoreText.text = "Score: " + score.ToString();
     soundManager.PlayTheme();
 }
 private void Awake()
 {
     if (Instance == null)
     {
         Instance = this;
     }
     //else
     //Destroy(gameObject);
 }
示例#9
0
            public static PacketWriter ShowShop(ShopScript shop, int npcId)
            {
                List <ShopItem> items = shop.ShopItems;
                PacketWriter    pw    = new PacketWriter(SendHeader.NpcShop);

                pw.WriteByte(0);
                pw.WriteInt(0);
                pw.WriteInt(npcId);
                pw.WriteByte(0);
                pw.WriteShort((short)items.Count);

                foreach (ShopItem item in items)
                {
                    pw.WriteInt(item.Id);
                    pw.WriteInt(item.Price);
                    pw.WriteByte(0);
                    pw.WriteInt(item.ReqItemId);
                    pw.WriteInt(item.ReqItemQuantity);
                    pw.WriteInt(0);        //unk
                    pw.WriteInt(0);        //unk
                    pw.WriteInt(0);        //unk
                    pw.WriteZeroBytes(22); //v158
                    pw.WriteLong(MapleFormatHelper.GetMapleTimeStamp(-2));
                    pw.WriteLong(MapleFormatHelper.GetMapleTimeStamp(-1));
                    pw.WriteInt(item.Tab);
                    pw.WriteByte(0);
                    pw.WriteByte(0);
                    pw.WriteInt(0);
                    pw.WriteZeroBytes(3); //v158
                    MapleItemType itemType = ItemConstants.GetMapleItemType(item.Id);
                    if (itemType == MapleItemType.Bullet || itemType == MapleItemType.ThrowingStar)
                    {
                        pw.WriteZeroBytes(6);
                        pw.WriteShort((short)(BitConverter.DoubleToInt64Bits((double)item.Price) >> 48));
                        pw.WriteShort(item.BulletCount); //Todo, correct max amount
                    }
                    else
                    {
                        pw.WriteShort((short)item.DefaultQuantity);
                        pw.WriteShort((short)item.MaximumPurchase);
                    }
                    pw.WriteByte(0);
                    pw.WriteInt(0);
                    pw.WriteInt(0);
                    pw.WriteInt(0);
                    pw.WriteInt(0);

                    pw.WriteLong(9410165);
                    pw.WriteLong(9410166);
                    pw.WriteLong(9410167);
                    pw.WriteLong(9410168);
                    //pw.WriteBytes(Functions.HexToBytes("75968F000000000076968F000000000077968F000000000078968F0000000000"));//no idea
                }
                return(pw);
            }
示例#10
0
 public void purchase()
 {
     if (isSkin)
     {
         //get the object's name
         currentskins = ShopScript.currentskins;
         contains     = false;
         //checks if already purchased
         for (int i = 0; i < currentskins.Length; i++)
         {
             if (currentskins [i] == button.name)
             {
                 contains = true;
             }
         }
         if (contains == false)
         {
             //if does not exist, then add to existing.
             //purchase.
             int newcoins = PlayerPrefs.GetInt("coins") - cost;
             if (newcoins >= 0)
             {
                 PlayerPrefs.SetInt("coins", newcoins);
                 List <string> currentskinsList = new List <string> ();
                 currentskinsList.AddRange(currentskins);
                 currentskinsList.Add(this.gameObject.name);
                 currentskins            = currentskinsList.ToArray();
                 ShopScript.currentskins = currentskinsList.ToArray();
                 PlayerPrefsX.SetStringArray("purchased", ShopScript.currentskins);
                 ShopScript.loadcoinvalue(newcoins);
                 button.image.overrideSprite = button.image.sprite;
                 PlayerPrefs.Save();
             }
         }
         else if (contains == true)
         {
             //if already contains, select skin and use it.
             PlayerPrefs.SetString("currentskin", this.gameObject.name);
             PlayerPrefs.Save();
             canvas.GetComponent <ShopScript> ().resetSkinsButtons();
         }
     }
     else
     {
         string buttonname = button.name;
         int    newcoins   = PlayerPrefs.GetInt("coins") - cost;
         if (newcoins >= 0)
         {
             PlayerPrefs.SetInt(buttonname, (PlayerPrefs.GetInt(buttonname) + 1));
             PlayerPrefs.SetInt("coins", newcoins);
             ShopScript.loadcoinvalue(newcoins);
             text.GetComponent <Text>().text = cost + " (" + PlayerPrefs.GetInt(button.name) + ")";
         }
     }
 }
示例#11
0
 private void CloseDoor()
 {
     foreach (GameObject openShop in SpawnManager.instance.GetOpenShops())
     {
         if (Vector3.Distance(this.transform.position, openShop.transform.position) <= range)
         {
             ShopScript shop = openShop.GetComponent <ShopScript>();
             shop.Enable = false;
         }
     }
 }
示例#12
0
 public void setBought()
 {
     if (infoButton != null)
     {
         Vector3 newPos = new Vector3(170, 0, 0);
         infoButton.GetComponent <RectTransform>().anchoredPosition = newPos;
         this.gameObject.SetActive(false);
         boughtText.text = "Bought!";
         ShopScript.NewPrice();
     }
 }
示例#13
0
    void Awake()
    {
        if (instance == null)
        {
            instance = this;
        }

        else if (instance != this)
        {
            Destroy(gameObject);
        }
    }
 void Start()
 {
     playerManager = GetComponent <CharacterManager_NET>();
     myShopping    = GetComponent <ShopScript>();
     canvas        = GameObject.Find("Canvas").GetComponent <Canvas>();
     healthbarUI   = Instantiate(healthbarUI_prefab) as GameObject;
     healthBar     = healthbarUI.transform.GetChild(0).GetComponent <Image>();
     healthbarUI.transform.SetParent(canvas.transform, false);
     health = maxHealth;
     myLine = this.GetComponent <LineRenderer>();
     setName();
     iceBlock.SetActive(false);
     curseMarker.SetActive(false);
     playerID = GetComponent <CharacterManager_NET>().playerID;
 }
示例#15
0
	//bool showShipStat;
	//bool shipWasAnimated;
	//bool submarineWasAnimated;


    // Use this for initialization
    void Start () {
		_instance = this;

		//shipWasAnimated = false;
		//submarineWasAnimated = false;

		transform.FindChild ("back_btn").GetComponent<Button>().onClick.AddListener(BackClick);
		//transform.FindChild ("money_field").GetComponent<Button> ().onClick.AddListener (ToggleSide);

		transform.FindChild("money_field").GetComponent<Button>().onClick.AddListener(OpenShopOverlay);

		transform.FindChild ("ship_btn_off").GetComponent<Button> ().onClick.AddListener (delegate { ToggleSide (true); });
		transform.FindChild ("submarine_btn_off").GetComponent<Button> ().onClick.AddListener (delegate { ToggleSide (false); });

    }
示例#16
0
 void Start()
 {
     //CHANGE WATCH OUT CAN GLITCH
     talkedToGrandma = true;
     shop            = GameObject.Find("Mobile").GetComponent <ShopScript>();
     PoliceStars     = GameObject.Find("PoliceStars");
     canvas          = GameObject.Find("Canvas");
     animator        = GetComponent <Animator>();
     if (textView != null)
     {
         textView.SetActive(false);
         talkText.gameObject.SetActive(false);
     }
     audioSteal  = GameObject.Find("Coin_Grab_Sound");
     audioScream = GameObject.Find("Scream_Sound");
     audioPlace  = GameObject.Find("Place_Object_Sound");
 }
示例#17
0
    public void NotifyEnemyDestroy(GameObject enemy)
    {
        spawnedEnemies.Remove(enemy);

        foreach (GameObject e in spawnedDefenders)
        {
            e.GetComponentInChildren <Defender_Controller>().NotifyEnemyDead(enemy);
        }
        // Add currency and score
        ShopScript shop = GetComponent <ShopScript>();

        shop.AddScore(enemy.GetComponentInChildren <EnemyController>().GetMaxHealth());
        shop.AddCurrency(enemy.GetComponentInChildren <EnemyController>().GetMaxHealth());
        PlayerPrefs.SetFloat("lastScore", shop.getScore());

        Destroy(enemy);
    }
示例#18
0
        public void BuyItem(int purchaseId, short index, short quantity)
        {
            ScriptInstance.State     = 1;
            ScriptInstance.Selection = index;
            ShopScript shopScript = (ShopScript)ScriptInstance;
            var        shopItems  = shopScript.ShopItems;

            if (shopItems != null)
            {
                if (index >= 0 && index < shopItems.Count)
                {
                    ShopItem item = shopItems[index];
                    if (item.Id == purchaseId)
                    {
                        byte response = shopScript.Character.BuyItem(item, quantity);
                        Client.SendPacket(Packets.ShopTransactionResponse(response));
                    }
                }
            }
        }
示例#19
0
        /// <summary>
        /// Callback for clicking on an inventory cell (should be renamed, but
        /// won't be, to avoid last-minute bugs from not updating all
        /// references).
        /// If the player is in front of the weapon shop, the weapon is sold.
        /// If the player is in the dungeon, the weapon will be equipped when
        /// the game is unpaused.
        /// </summary>
        /// <param name="slot">associated weapon slot</param>
        public void sellWeapon(int slot)
        {
            if (playerShoot == null)
            {
                // try to find it again
                playerShoot = GameObject.FindGameObjectWithTag("Player")?.GetComponentInChildren <PlayerShoot>(true);
            }
            if (UnityEngine.SceneManagement.SceneManager.GetActiveScene().name == "Dungeon" && playerShoot.guns.Count > slot)
            {
                playerShoot.slot = slot;
                return;
            }
            if (playerShoot.guns.Count <= 1)    // disallow selling last weapon
            {
                return;
            }
            if (shopkeep == null)
            {
                GameObject shop = GameObject.Find("WeaponShop");
                if (shop == null)
                {
                    return;
                }
                shopkeep = shop.GetComponentInChildren <ShopScript>();
            }
            if (!shopkeep.playerIsInTriggerZone || playerShoot.guns.Count <= slot)
            {
                return;
            }
            GameObject  gun = playerShoot.guns[slot];
            WeaponStats w   = gun.GetComponentInChildren <WeaponStats>(true);

            playerShoot.guns.Remove(gun);
            StateManager.cashOnHand += w.buybackPrice;
            Debug.Log($"Sold {w.fullName} for {w.buybackPrice}");
            audioS.PlayOneShot(sellSound, Settings.volume);
            // Guns should be attached to a transform that positions them on the player
            Destroy(w.bulletPoolObject);
            Destroy(gun.transform.parent.gameObject);
            updateWeaponSlots();
        }
示例#20
0
 private void Awake()
 {
     instance = this;
 }
示例#21
0
    void Start()
    {
        bs           = gameObject.GetComponent <BattleScript>();
        rs           = gameObject.GetComponent <RestScript>();
        es           = gameObject.GetComponent <EventScript>();
        ss           = gameObject.GetComponent <ShopScript>();
        bss          = gameObject.GetComponent <BossScript>();
        currentLevel = 0;
        stageHeight  = 8;
        stageLength  = 3;
        Levels       = new GameObject[stageHeight + 1, stageLength];
        NodeTypes    = new int[stageHeight - 1, stageLength];

        //Decide what node type is on each point
        for (int y = 0; y < stageHeight - 1; y++)
        {
            bool empty = false;
            for (int x = 0; x < stageLength; x++)
            {
                //maximum one empty per row
                if (!empty)
                {
                    NodeTypes[y, x] = Random.Range(0, 101);
                }
                else
                {
                    NodeTypes[y, x] = Random.Range(21, 101);
                }
                if (NodeTypes[y, x] < 11)
                {
                    empty = true;
                }
            }
        }

        //Generate the nodes
        for (int y = 0; y < stageHeight - 1; y++)
        {
            for (int x = 0; x < stageLength; x++)
            {
                switch (NodeTypes[y, x])
                {
                case int n when n <= 70 && n >= 21:
                    Levels[y, x] = Instantiate(BattleNode, new Vector3(0, 0, 0), Quaternion.identity);
                    bs.LinkBattleNode(Levels[y, x].GetComponent <Button>());
                    break;

                case int n when n <= 80 && n >= 71:
                    Levels[y, x] = Instantiate(EventNode, new Vector3(0, 0, 0), Quaternion.identity);
                    es.LinkEventNode(Levels[y, x].GetComponent <Button>());
                    break;

                case int n when n <= 90 && n >= 81:
                    Levels[y, x] = Instantiate(RestNode, new Vector3(0, 0, 0), Quaternion.identity);
                    rs.LinkRestNode(Levels[y, x].GetComponent <Button>());
                    break;

                case int n when n <= 100 && n >= 91:
                    Levels[y, x] = Instantiate(ShopNode, new Vector3(0, 0, 0), Quaternion.identity);
                    ss.LinkShopNode(Levels[y, x].GetComponent <Button>());
                    break;

                default:
                    Levels[y, x] = Instantiate(EmptyNode, new Vector3(0, 0, 0), Quaternion.identity);
                    break;
                }
                Levels[y, x].gameObject.name = "Node" + y + x;
                Levels[y, x].transform.SetParent(NodeContainer.transform);
                Levels[y, x].transform.SetPositionAndRotation((Levels[y, x].transform.parent.position + new Vector3((x * 420) - 420, (y * 600) - 2400, 0)), Quaternion.identity);
            }
        }

        //Rest
        for (int x = 0; x < stageLength; x++)
        {
            Levels[stageHeight - 1, x] = Instantiate(RestNode, new Vector3(0, 0, 0), Quaternion.identity);
            Levels[stageHeight - 1, x].gameObject.name = "Node" + (stageHeight - 1) + x;
            Levels[stageHeight - 1, x].transform.SetParent(NodeContainer.transform);
            Levels[stageHeight - 1, x].transform.SetPositionAndRotation((Levels[(stageHeight - 1), x].transform.parent.position + new Vector3((x * 420) - 420, ((stageHeight - 1) * 600) - 2400, 0)), Quaternion.identity);
            rs.LinkRestNode(Levels[stageHeight - 1, x].GetComponent <Button>());
        }

        //Boss
        Levels[stageHeight, 1] = Instantiate(BossNode, new Vector3(0, 0, 0), Quaternion.identity);
        Levels[stageHeight, 1].gameObject.name = "Node" + stageHeight + "1";
        Levels[stageHeight, 1].transform.SetParent(NodeContainer.transform);
        Levels[stageHeight, 1].transform.SetPositionAndRotation((Levels[stageHeight, 1].transform.parent.position + new Vector3((1 * 420) - 420, (stageHeight * 600) - 2400, 0)), Quaternion.identity);
        Levels[stageHeight, 1].GetComponent <Button>().interactable = false;
        bss.LinkBossNode(Levels[stageHeight, 1].GetComponent <Button>());
        //Disable nodes above first row
        for (int y = 1; y < stageHeight; y++)
        {
            for (int x = 0; x < stageLength; x++)
            {
                Levels[y, x].GetComponent <Button>().interactable = false;
            }
        }
        //connecting lines? Not sure yet how to do
        //for (int y = 0; y < 2; y++)
        //{
        //    for (int x = 0; x < 3; x++)
        //    {
        //    }
        //}
    }
示例#22
0
 private void Start()
 {
     instance   = this;
     instanceGO = gameObject;
 }
示例#23
0
        public override bool itemCallBack(string tab, string name, int vale, int num)
        {
            string[] weapons = { "Whip2",   "Whip3",    "Knife",     "Rapier",      "Axe",        "Katana",    "Shuriken", "R-Shuriken", "E-Spear", "Flare Gun", "Bomb",
                                 "Chakram", "Caltrops", "Clay Doll", "Origin Seal", "Birth Seal", "Life Seal", "Death Seal" };

            if (this.item_copunter > 2)
            {
                return(false);
            }
            this.true_name[this.item_copunter] = name;
            if (this.sys.isAnkJewel(name))
            {
                name = "Ankh Jewel";
            }
            else if (this.sys.isMap(name))
            {
                name = "Map";
            }
            this.item_id[this.item_copunter] = name;

            if (name.Contains("Mantra") && !name.Equals("Mantra"))
            {
                this.icon[this.item_copunter]             = L2SystemCore.getShopIconSprite(L2SystemCore.getItemData("Mantra"));
                this.shop_item[this.item_copunter].sprite = this.icon[this.item_copunter];

                string mojiName = name.Equals("Mantra10") ? "mantra1stM10" : "mantra1stM" + name.Substring(6, 1);
                this.item_name[this.item_copunter].text = this.sys.getMojiText(true, this.sys.mojiSheetNameToNo(tab, this.sys.getMojiScript(mojiScriptType.system)),
                                                                               this.sys.mojiIdToNo(tab, mojiName, this.sys.getMojiScript(mojiScriptType.system)), this.sys.getNowLangage(), this.sys.getMojiScript(mojiScriptType.system));
            }
            else
            {
                if (name.Equals("Map"))
                {
                    this.icon[this.item_copunter] = L2SystemCore.getMapIconSprite(L2SystemCore.getItemData("Map"));
                }
                else if (name.Equals("MSX"))
                {
                    this.icon[this.item_copunter] = L2SystemCore.getShopIconSprite(L2SystemCore.getItemData("MSX3p"));
                }
                else if (name.Contains("Sacred Orb"))
                {
                    this.icon[this.item_copunter] = L2SystemCore.getMenuIconSprite(L2SystemCore.getItemData("Sacred Orb"));
                    name = "Sacred Orb";
                }
                else if (name.Contains("Crystal S"))
                {
                    this.icon[this.item_copunter] = L2SystemCore.getShopIconSprite(L2SystemCore.getItemData("Crystal S"));
                    name = "Crystal S";
                }
                else if (Array.IndexOf(weapons, name) > -1)
                {
                    this.icon[this.item_copunter] = L2SystemCore.getMenuIconSprite(L2SystemCore.getItemData(name));
                }
                else
                {
                    this.icon[this.item_copunter] = ShopScript.Load("Textures/icons_shops", name);
                }

                this.shop_item[this.item_copunter].sprite = this.icon[this.item_copunter];
                this.item_name[this.item_copunter].text   = this.sys.getMojiText(true, this.sys.mojiSheetNameToNo(tab, this.sys.getMojiScript(mojiScriptType.item)),
                                                                                 this.sys.mojiIdToNo(tab, name, this.sys.getMojiScript(mojiScriptType.item)), this.sys.getNowLangage(), this.sys.getMojiScript(mojiScriptType.item));
            }

            this.item_value[this.item_copunter] = vale;
            if (vale > 999)
            {
                this.item_valu[this.item_copunter].text = L2Math.numToText(vale, 4);
            }
            else
            {
                this.item_valu[this.item_copunter].text = L2Math.numToText(vale, 3);
            }
            this.item_num[this.item_copunter] = num;
            this.item_copunter++;
            return(true);
        }
示例#24
0
 // Use this for initialization
 void Start()
 {
     shop     = GameObject.FindGameObjectWithTag("ShopMenuUI").GetComponent <ShopScript>();
     myImage  = GetComponent <Image>();
     myButton = GetComponent <Button>();
 }