// Use this for initialization
	void Start () 
	{
		if (viewCamera == null)
			viewCamera = GameObject.Find("GUIBoxCamera").GetComponent<Camera>();
		
		sprite = GetComponent<tk2dSprite>();
		
		// Change this to use animated sprites if necessary
		// Same concept here, lookup Ids and call Play(xxx) instead of .spriteId = xxx
		buttonDownSpriteId = sprite.GetSpriteIdByName(buttonDownSprite);
		buttonUpSpriteId = sprite.GetSpriteIdByName(buttonUpSprite);
		buttonPressedSpriteId = sprite.GetSpriteIdByName(buttonPressedSprite);
		
		if (collider == null)
		{
			BoxCollider newCollider = gameObject.AddComponent<BoxCollider>();
			Vector3 colliderExtents = newCollider.extents;
			colliderExtents.z = 0.2f;
			newCollider.extents = colliderExtents;
		}	
		
		monsterSprite = transform.FindChild("MonsterImage").GetComponent<tk2dSprite>();
		monsterSprite.enabled = false;
		LoadMonster();
		
		StartCoroutine(coHandleMouseEnter());
	}
Beispiel #2
0
    public IEnumerator EventsEffect(int i)
    {
        selectSymbol = gameObject.GetComponent <tk2dSprite>();
        for (int n = 0; n < 2; n++)
        {
            if (i == 3 || i == 7 || i == 10 || i == 13)
            {
                selectSymbol.spriteId = selectSymbol.GetSpriteIdByName("3");
            }
            if (i == 1 || i == 4 || i == 14 || i == 8)
            {
                selectSymbol.spriteId = selectSymbol.GetSpriteIdByName("4");
            }
            if (i == 2 || i == 6 || i == 11 || i == 15)
            {
                selectSymbol.spriteId = selectSymbol.GetSpriteIdByName("2");
            }
            if (i == 0 || i == 5 || i == 9 || i == 12)
            {
                selectSymbol.spriteId = selectSymbol.GetSpriteIdByName("1");
            }
            yield return(new WaitForSeconds(0.2f));

            selectSymbol.spriteId = selectSymbol.GetSpriteIdByName("quanquan");
            yield return(new WaitForSeconds(0.2f));
        }
    }
Beispiel #3
0
    public void printValues()
    {
        GemsText.text     = gemsAmount.ToString() + "\n" + gemsString.text;
        GemsText.maxChars = GemsText.text.Length;
        GemsText.Commit();

        CoinsText.text     = coinsAmount.ToString() + "\n" + coinsString.text;
        CoinsText.maxChars = CoinsText.text.Length;
        CoinsText.Commit();

        if (gemsAmount < 10)
        {
            GemsIcon.spriteId  = GemsIcon.GetSpriteIdByName("gems");
            CoinsIcon.spriteId = CoinsIcon.GetSpriteIdByName("gold1");
        }
        else if (gemsAmount < 40)
        {
            GemsIcon.spriteId  = GemsIcon.GetSpriteIdByName("gem2");
            CoinsIcon.spriteId = CoinsIcon.GetSpriteIdByName("gold2");
        }
        else if (gemsAmount < 100)
        {
            GemsIcon.spriteId  = GemsIcon.GetSpriteIdByName("gem4");
            CoinsIcon.spriteId = CoinsIcon.GetSpriteIdByName("gold3");
        }
        else
        {
            GemsIcon.spriteId  = GemsIcon.GetSpriteIdByName("gem6");
            CoinsIcon.spriteId = CoinsIcon.GetSpriteIdByName("gold4");
        }
    }
Beispiel #4
0
    void CollectIconSate(Action <int> action)
    {
        switch (this.BuildingLogicData.BuildingIdentity.buildingType)
        {
        case BuildingType.GoldMine:
            m_ResourceIcon.spriteId = m_ResourceIcon.GetSpriteIdByName(ClientSystemConstants.SCENE_RESOURCE_ICON_DICTIONARY[ResourceType.Gold]);
            if (this.BuildingLogicData.CurrentBuilidngState != BuildingEditorState.Normal || this.BuildingBehavior.IsClick)
            {
                action.Invoke(0);
            }
            else
            {
                action.Invoke(SystemFunction.CheckCollectValidity(this.BuildingLogicData, ResourceType.Gold));
            }
            break;

        case BuildingType.Farm:
            m_ResourceIcon.spriteId = m_ResourceIcon.GetSpriteIdByName(ClientSystemConstants.SCENE_RESOURCE_ICON_DICTIONARY[ResourceType.Food]);
            if (this.BuildingLogicData.CurrentBuilidngState != BuildingEditorState.Normal || this.BuildingBehavior.IsClick)
            {
                action.Invoke(0);
            }
            else
            {
                action.Invoke(SystemFunction.CheckCollectValidity(this.BuildingLogicData, ResourceType.Food));
            }
            break;
        }
        //if (this.BuildingLogicData.BuildingType == BuildingType.Farm)
        //{
        //    print("name =" + this.BuildingLogicData.Name);
        //    print("prefabName = " + this.gameObject);
        //    print("BuildingLogicData.CurrentStoreFood =" + BuildingLogicData.CurrentStoreFood);
        //}
    }
Beispiel #5
0
    // Update is called once per frame
    void Update()
    {
        GameObject obj = GameObject.FindGameObjectWithTag(constant.TAG_PLAYER);

        if (obj == null)
        {
            return;
        }

        char_property pro = obj.GetComponent <char_property> ();
        //Debug.Log ("pro hp:" + pro.MaxHp + "," + pro.Hp);

        int totalHp = pro.MaxHp;

        if (mHps.Count > pro.MaxHp)
        {
            for (int i = mHps.Count - 1; i >= pro.MaxHp; --i)
            {
                GameObject hpObj = mHps[i];
                mHps.Remove(hpObj);
                Destroy(hpObj);
            }
        }
        else if (mHps.Count < pro.MaxHp)
        {
            int oldnum = mHps.Count;
            int num    = pro.MaxHp - mHps.Count;
            for (int i = 0; i < num; ++i)
            {
                Vector3 v = getPosition(i + oldnum);
                //GameObject hpObj = (GameObject)Instantiate(Resources.Load(hpPath),v,Quaternion.identity);
                GameObject prefab = Resources.Load <GameObject> (hpPath);
                GameObject hpObj  = Instantiate(prefab) as GameObject;

                hpObj.transform.parent        = this.gameObject.transform;
                hpObj.transform.localPosition = v;
                mHps.Add(hpObj);
            }
        }

        //Component charProperty = obj.GetComponent<"char_property">();
        //int hp = charProperty.getHp();

        int hp = pro.Hp;

        for (int i = 0; i < totalHp; ++i)
        {
            GameObject hpSprObj = mHps[i];             // GameObject.Find("hp_child" + (i+1));
            tk2dSprite spr      = hpSprObj.GetComponentInChildren <tk2dSprite>();
            if (i < hp)
            {
                spr.SetSprite(spr.GetSpriteIdByName("heart_full"));
            }
            else
            {
                spr.SetSprite(spr.GetSpriteIdByName("heart_empty"));
            }
        }
    }
Beispiel #6
0
        public static bool SpawnerMain_SpawnItemSprite(SpawnerMain __instance, InvItem item, tk2dSprite itemImage, Item newItem)
        {
            try { itemImage.SetSprite(__instance.gc.spawnerMain.itemSprites, item.spriteName); } catch { }
            Material mat = itemImage.CurrentSprite.material;

            itemImage.GetComponent <Renderer>().sharedMaterial = mat;
            try
            {
                if (!__instance.gc.serverPlayer)
                {
                    __instance.itemLightUp        = Instantiate(mat);
                    __instance.itemLightUp.shader = __instance.gc.lightUpShader;
                }
                newItem.objectSprite.sprH.GetComponent <Renderer>().sharedMaterial = mat;
                newItem.objectSprite.sprH.SetSprite(itemImage.spriteId);
            }
            catch
            {
                try
                {
                    try { newItem.objectSprite.GetComponent <Renderer>().sharedMaterial = mat; }
                    catch { Debug.LogError("Couldn't set highlight for item 1: " + newItem); }
                    try { newItem.objectSprite.spr.GetComponent <Renderer>().sharedMaterial = mat; }
                    catch { Debug.LogError("Couldn't set highlight for item 2: " + newItem); }
                    try { newItem.objectSprite.sprH.GetComponent <Renderer>().sharedMaterial = mat; }
                    catch { Debug.LogError("Couldn't set highlight for item 3: " + newItem); }
                    newItem.objectSprite.transform.Find("Highlight").GetComponent <tk2dSprite>().SetSprite(itemImage.spriteId);
                    Debug.LogError("SPAWNN");
                }
                catch
                {
                    Debug.LogError("Couldn't set highlight for item 4: " + newItem);
                }
            }
            if (item.invItemName == VanillaItems.Money)
            {
                if (item.invItemCount is 1)
                {
                    itemImage.SetSprite(itemImage.GetSpriteIdByName("MoneyA"));
                    item.shadowOffset = 6;
                }
                else if (item.invItemCount > 1 && item.invItemCount <= 5)
                {
                    itemImage.SetSprite(itemImage.GetSpriteIdByName("MoneyB"));
                    item.shadowOffset = 4;
                }
                else if (item.invItemCount > 5 && item.invItemCount < 10)
                {
                    itemImage.SetSprite(itemImage.GetSpriteIdByName("MoneyC"));
                    item.shadowOffset = 4;
                }
                else
                {
                    item.shadowOffset = 3;
                }
            }

            return(false);
        }
Beispiel #7
0
    // protected

    // private

    // properties
    #endregion

    #region Unity API
    #endregion

    #region Public Functions
    #endregion

    #region ControllerButton
    public override void OnTouchOver(TouchEvent touchEvent)
    {
        base.OnTouchOver(touchEvent);

        AudioManager.Instance.PlaySFX(m_SFXClick);

        if (m_Sprite != null)
        {
            m_Sprite.spriteId = m_Sprite.GetSpriteIdByName(m_HoverSpriteName);
        }
    }
Beispiel #8
0
 /// <summary>
 /// Stand on a respawn point to activate it. You could play a particle effect of something here.
 /// </summary>
 override public void DoAction(RaycastCollider collider, RaycastCharacterController character)
 {
     if (RespawnPoint.currentRespawnPoint is RespawnFlag2DTK)
     {
         ((RespawnFlag2DTK)RespawnPoint.currentRespawnPoint).Down();
     }
     if (collider.direction == RC_Direction.DOWN)
     {
         RespawnPoint.currentRespawnPoint = this;
     }
     sprite.SetSprite(sprite.GetSpriteIdByName(flagUpSprite));
 }
Beispiel #9
0
    private void OnTriggerEnter(Collider other)
    {
        ObstacleHandle handle = other.GetComponent <ObstacleHandle>();

        if (m_HoveringObstacleHandle == null && handle != null)
        {
            if (!m_IsGrabbing)
            {
                m_Asset.spriteId = m_Asset.GetSpriteIdByName(m_HandReadyAssetName);
            }

            m_HoveringObstacleHandle = handle;
        }
    }
 private void muteSound()
 {
     if (isMute == false)
     {
         spirteMute.spriteId = spirteMute.GetSpriteIdByName("Mute");
         isMute = true;
         AudioListener.volume = 0;
     }
     else
     {
         spirteMute.spriteId = spirteMute.GetSpriteIdByName("OptionButton");
         isMute = false;
         AudioListener.volume = 1;
     }
 }
Beispiel #11
0
    // Room switching code
    public void switchRoom(Room newRoom, Vector2 newPlayerGridPos)
    {
        // First up, remove the player from our current grid piece list
        _gridPieces.Remove(_player);
        Vector2 actualPos = toActualCoordinates(newPlayerGridPos);

        _player.x = actualPos.x;
        _player.y = actualPos.y;
        _player.resetGridPos();
        _player.roomStartPos = newPlayerGridPos;

        // Deactivate all the current room grid pieces
        foreach (GridPiece piece in _gridPieces)
        {
            piece.gameObject.SetActive(false);
        }

        // Switch!
        _currentRoom          = newRoom;
        _floorSprite.spriteId = _floorSprite.GetSpriteIdByName(newRoom.floorTilesName);
        _gridPieces           = newRoom.gridPieces;
        _gridPieces.Add(_player);

        // Reactivate all the pieces.
        foreach (GridPiece piece in _gridPieces)
        {
            piece.gameObject.SetActive(true);
        }
    }
    IEnumerator _Coro_FishCardViewing(Fish f)
    {
        //tk2dSprite prefabTargetFishCard = null;
        string nameSpr;

        if (mFishTypeIdToCard.TryGetValue(f.TypeIndex, out nameSpr))
        {
            mSprCard.spriteId = mSprCard.GetSpriteIdByName(nameSpr);
        }

        Vector3 localPos = new Vector3(98.5615488F, 55.5742848F, -19.67065344F);

        float rotateOffset = 4.42762752F;

        mTsCard.localScale = Vector3.one;
        float rotateSpd   = 640F;
        float rotateAngle = 0F;

        while (true)
        {
            mTsCard.localPosition = localPos + new Vector3(rotateOffset * Mathf.Sin(rotateAngle * Mathf.Deg2Rad), rotateOffset * Mathf.Cos(rotateAngle * Mathf.Deg2Rad), 0F);

            rotateAngle += Time.deltaTime * rotateSpd;

            yield return(0);
        }
    }
Beispiel #13
0
        void Start()
        {
            mState1             = State1.ScaleUp;
            mState2_IsFadingOut = false;
            mShakeDirects       = new Vector3[] {
                new Vector3(-1F, 1F, 0F)
                , new Vector3(1F, -1.2F, 0F)
                , new Vector3(1.2F, 1F, 0F)
                , new Vector3(-1.2F, -0.8F, 0F)
            };

            mSprWeb = Pool_GameObj.GetObj(Prefab_GoSpriteWeb).GetComponent <tk2dSprite>();
            if (NameSprite != null && NameSprite != "")
            {
                mSprWeb.spriteId = mSprWeb.GetSpriteIdByName(NameSprite);
            }
            Transform ts = mSprWeb.transform;

            mSprWeb.gameObject.SetActive(true);
            ts.parent        = transform;
            ts.localPosition = Vector3.zero;
            Color c = ColorInitialize;

            c.a           = 1F;
            mSprWeb.color = c;
            mTsWeb        = ts;

            mTimeWaitFadeout = TimeWebScaleUp + TimeShake - TimeFadeOut;
            mColorWeb        = mSprWeb.color;
        }
Beispiel #14
0
    void Start()
    {
        mState1 = State1.ScaleUp;
        mState2_IsFadingOut = false;
        mShakeDirects = new Vector3[]{
                        new Vector3(-1F,1F,0F)
                        ,new Vector3(1F,-1.2F,0F)
                        ,new Vector3(1.2F,1F,0F)
                        ,new Vector3(-1.2F,-0.8F,0F)
                };

        mSprWeb = Pool_GameObj.GetObj(Prefab_GoSpriteWeb).GetComponent<tk2dSprite>();
        if (NameSprite != null && NameSprite != "")
            mSprWeb.spriteId = mSprWeb.GetSpriteIdByName(NameSprite);
        Transform ts = mSprWeb.transform;
        mSprWeb.gameObject.SetActive(true);
        ts.parent = transform;
        ts.localPosition = Vector3.zero;
        Color c = ColorInitialize;
        c.a = 1F;
        mSprWeb.color = c;
        mTsWeb = ts;

        mTimeWaitFadeout = TimeWebScaleUp + TimeShake - TimeFadeOut;
        mColorWeb = mSprWeb.color;
    }
Beispiel #15
0
    public void ShowNumber(int index)
    {
        if (number == null)
        {
            number = GetComponentInChildren <tk2dSprite>();
        }

        number.spriteId = number.GetSpriteIdByName(index.ToString());
    }
Beispiel #16
0
 private void DoSpawn()
 {
     hasSpawned = true;
     if (hitSpriteName != null && hitSpriteName.Length > 0)
     {
         sprite.SetSprite(sprite.GetSpriteIdByName(hitSpriteName));
     }
     spawnGameObject.SendMessage("Spawn", spawnForce, SendMessageOptions.DontRequireReceiver);
 }
Beispiel #17
0
 // Update is called once per frame
 void Update()
 {
     if (failed)
     {
         sprite.spriteId = sprite.GetSpriteIdByName("buttonFail");
     }
     else if (!active)
     {
         sprite.spriteId = sprite.GetSpriteIdByName("buttonOff");
     }
     else if (correctHit)
     {
         sprite.spriteId = sprite.GetSpriteIdByName("buttonHitFine");
     }
     else if (active)
     {
         sprite.spriteId = sprite.GetSpriteIdByName("buttonOn");
     }
 }
    void Evt_PlayerGatherFishInit(Player player, Fish fish, int gatherIdx)
    {
        tk2dSprite spr = Instantiate(PrefabSpr) as tk2dSprite;

        spr.spriteId = spr.GetSpriteIdByName(SpriteName[gatherIdx]);
        Transform tsSpr = spr.transform;

        tsSpr.parent        = TsPlayerGatherBGs[player.Idx];
        tsSpr.localPosition = LocalPoss[gatherIdx];
        tsSpr.localRotation = Quaternion.identity;
        //StartCoroutine(_Coro_FlashFishSpr(spr));
    }
    void OnEnable()
    {
        mSpr = GetComponent<tk2dSprite>();

        if (mSpr ==null ||SpriteNames == null || SpriteNames.Length == 0)
        {
            Debug.LogError("LocalPos_LanguageAutoSelect���������Աδ��ֵ����.");
            Destroy(this);
            return;
        }
        GameMain.EvtLanguageChange += Handle_LanguageChanged;
        mSpr.spriteId = mSpr.GetSpriteIdByName(SpriteNames[(int)GameMain.Singleton.BSSetting.LaguageUsing.Val]);
    }
Beispiel #20
0
    void OnEnable()
    {
        mSpr = GetComponent <tk2dSprite>();

        if (mSpr == null || SpriteNames == null || SpriteNames.Length == 0)
        {
            Debug.LogError("LocalPos_LanguageAutoSelectÓïÑÔ×é¼þ³ÉԱδ¸³Öµ´íÎó.");
            Destroy(this);
            return;
        }
        GameMain.EvtLanguageChange += Handle_LanguageChanged;
        mSpr.spriteId = mSpr.GetSpriteIdByName(SpriteNames[(int)GameMain.Singleton.BSSetting.LaguageUsing.Val]);
    }
Beispiel #21
0
    // Use this for initialization
    void Start()
    {
        if (viewCamera == null)
        {
            // Find a camera parent
            Transform node = transform;
            while (node && node.camera == null)
            {
                node = node.parent;
            }
            if (node && node.camera != null)
            {
                viewCamera = node.camera;
            }

            // ...otherwise, use the main camera
            if (viewCamera == null)
            {
                viewCamera = Camera.main;
            }
        }

        sprite = GetComponent <tk2dSprite>();

        // Change this to use animated sprites if necessary
        // Same concept here, lookup Ids and call Play(xxx) instead of .spriteId = xxx
        buttonDownSpriteId    = sprite.GetSpriteIdByName(buttonDownSprite);
        buttonUpSpriteId      = sprite.GetSpriteIdByName(buttonUpSprite);
        buttonPressedSpriteId = sprite.GetSpriteIdByName(buttonPressedSprite);

        if (collider == null)
        {
            BoxCollider newCollider     = gameObject.AddComponent <BoxCollider>();
            Vector3     colliderExtents = newCollider.extents;
            colliderExtents.z   = 0.2f;
            newCollider.extents = colliderExtents;
        }
    }
Beispiel #22
0
        private void Start()
        {
            mTs = transform;

            mDepth = Defines.GlobleDepth_PlayerTargeter + 0.001F * mPlayer.Idx; //玩家idx可能未初始化完

            mChangeTargetArea = GameMain.Singleton.WorldDimension;
            mStartLockArea    = GameMain.Singleton.WorldDimension;

            Spr_TargetMoving.spriteId = Spr_TargetMoving.GetSpriteIdByName(NameSprTargetMoving + mPlayer.Idx % 10);
            Spr_Target.spriteId       = Spr_Target.GetSpriteIdByName(NameSprTarget + mPlayer.Idx % 10);

            Spr_TargetMoving.gameObject.SetActive(false);
            Spr_Target.gameObject.SetActive(false);
        }
Beispiel #23
0
 public static void SetGameObjectSprite(GameObject obj, string spriteName)
 {
     if (obj != null)
     {
         tk2dSprite sprite = obj.GetComponent <tk2dSprite>();
         if (sprite != null)
         {
             sprite.spriteId = sprite.GetSpriteIdByName(spriteName);
         }
     }
     else
     {
         Debug.Log("obj is null is SetGameObjectSprite");
     }
 }
	void Awake()
	{
		startWavePanel = GameObject.Find("WavePanel").GetComponent<UIInteractivePanel>();
		startWaveButton = GameObject.Find("startWaveButton").GetComponent<UIButton>();	
		
		waveInfoPanel = GameObject.Find("WaveInfoPanel").GetComponent<UIPanel>();
		waveInfoScrollList = GameObject.Find("WaveInfoScrollList").GetComponent<UIScrollList>();
		waveInfoPanel.BringIn();
		
		heroWaveManager = GameObject.Find("WaveManager").GetComponent<HeroWaveManager>();
		heroWaveManager.onAllWaveEnemiesDefeated += HandleAllWaveEnemiesDefeated;
		heroWaveManager.onNextWaveReady += HandleOnNextWaveReady;
		heroWaveManager.onSpawnNewHero += HandleOnSpawnNewHero;
		
		waveButton = GameObject.Find("startWaveButton").GetComponent<tk2dSprite>();
		waveButton.spriteId = waveButton.GetSpriteIdByName(waveStartButtonName);
	}
Beispiel #25
0
    // Use this for initialization
    void Start()
    {
        // If we're generating from a seed
        if (seedGenerate)
        {
            Random.seed = _currentSeed;
        }
        _currentSeed = Random.seed;
        Random.seed  = _currentSeed;

        _instance = this;

        _inventory = (GameObject.Find("inventory") as GameObject).GetComponent <Inventory>();

        _audioSource = GetComponent <AudioSource>();

        _floorSprite = GetComponentInChildren <tk2dSprite>();

        _popupText = (Instantiate(popupTextPrefab) as GameObject).GetComponent <tk2dTextMesh>();
        _popupText.transform.parent = transform;
        _popupText.gameObject.SetActive(false);

        _piecesToRemove  = new List <GridPiece>();
        _piecesToDestroy = new List <GridPiece>();

        _gridWidth  = Globals.ROOM_WIDTH;
        _gridHeight = Globals.ROOM_HEIGHT;


        _currentGame = new ProcGame();

        _currentRoom          = _currentGame.startRoom;
        _player               = _currentGame.player;
        _floorSprite.spriteId = _floorSprite.GetSpriteIdByName(_currentRoom.floorTilesName);
        _gridPieces           = _currentRoom.gridPieces;
        foreach (GridPiece piece in _gridPieces)
        {
            piece.gameObject.SetActive(true);
        }

        // Begin the game
        addPlayerText("Hungry....");
    }
    void Evt_PlayerGatherFishActive(Player player, Fish fish, int gatherIdx)
    {
        tk2dSprite spr = Instantiate(PrefabSpr) as tk2dSprite;

        spr.spriteId = spr.GetSpriteIdByName(SpriteName[gatherIdx]);
        Transform tsSpr = spr.transform;

        tsSpr.parent        = TsPlayerGatherBGs[player.Idx];
        tsSpr.localPosition = LocalPoss[gatherIdx];
        tsSpr.localRotation = Quaternion.identity;

        //�ռ���������
        if (TsPlayerGatherBGs[player.Idx].childCount >= mFg.CountFishNeedGather)
        {
            StartCoroutine(_Coro_EffectFlashAllSpr(TsPlayerGatherBGs[player.Idx], mFg.TimeDelayBonus));
        }
        else
        {
            StartCoroutine(_Coro_FlashFishSpr(spr, 5F));
        }
    }
Beispiel #27
0
    void Start()
    {
        if (Prefab_FishLockabe == null)
        {
            Fish[]      prefabAllFish = GameMain.Singleton.FishGenerator.Prefab_FishAll;
            List <Fish> tmpLst        = new List <Fish>();
            foreach (Fish f in prefabAllFish)
            {
                if (f.IsLockable)
                {
                    tmpLst.Add(f);
                }
            }

            Prefab_FishLockabe = tmpLst.ToArray();
        }

        mTs     = transform;
        mPlayer = GetComponent <Player>();


        mDepth = Defines.GlobleDepth_PlayerTargeter + 0.001F * mPlayer.Idx;//����idx����δ��ʼ����
        if (GameMain.Singleton.IsScreenNet() &&
            GameMain.Singleton.BSSetting.IsBulletCrossWhenScreenNet.Val)
        {
            mChangeTargetArea = GameMain.Singleton.WorldDimension;
        }
        else
        {
            mChangeTargetArea = mPlayer.AtScreenArea;
        }
        mStartLockArea = mPlayer.AtScreenArea;

        Spr_TargetMoving.spriteId = Spr_TargetMoving.GetSpriteIdByName(NameSprTargetMoving + mPlayer.Idx % 10);
        Spr_Target.spriteId       = Spr_Target.GetSpriteIdByName(NameSprTarget + mPlayer.Idx % 10);

        Spr_TargetMoving.GetComponent <Renderer>().enabled = false;
        Spr_Target.GetComponent <Renderer>().enabled       = false;
    }
 void Update()
 {
     if (Input.GetKeyDown(KeyCode.A))
     {
         sprite.color = Color.red;
     }
     if (Input.GetKeyDown(KeyCode.S))
     {
         sprite.color = Color.white;
     }
     if (Input.GetKeyDown(KeyCode.Q))
     {
         sprite.scale = new Vector3(2, 2, 2);
     }
     if (Input.GetKeyDown(KeyCode.W))
     {
         sprite.SetSprite("crate");
     }
     if (Input.GetKeyDown(KeyCode.Z))
     {
         int spriteId = sprite.GetSpriteIdByName("Rock");
         sprite.SetSprite(spriteId);
     }
 }
Beispiel #29
0
    public void ConstructGird()
    {
        this.m_GridSpriteList = new List <tk2dSprite>();
        for (int i = 0; i < ClientSystemConstants.BUILDING_TILE_MAP_SIZE.height; i++)
        {
            for (int j = 0; j < ClientSystemConstants.BUILDING_TILE_MAP_SIZE.width; j++)
            {
                if (BattleMapData.Instance.GridArray[i, j] != GridType.Out)
                {
                    float      depth      = this.m_GridPrefab.transform.position.z;
                    GameObject gridObject = (GameObject)ObjectPoolController.InstantiateWithoutPool(this.m_GridPrefab);                    //GameObject.Instantiate(this.m_GridPrefab) as GameObject;
                    Vector3    position   = PositionConvertor.GetWorldPositionFromBuildingTileIndex
                                                (new TilePosition(j, i));
                    gridObject.transform.position = new Vector3(position.x, position.y, depth);
                    gridObject.transform.parent   = this.m_ParentNode;
                    tk2dSprite gridSprite = gridObject.GetComponentInChildren <tk2dSprite>();
                    gridSprite.spriteId = gridSprite.GetSpriteIdByName(BattleMapData.Instance.GridArray[i, j].ToString());
                    this.m_GridSpriteList.Add(gridSprite);
                }
            }
        }

        this.DisplayGrid();
    }
Beispiel #30
0
 public int getSpriteIdByName(string spr_name)
 {
     return(scenery_sprite.GetSpriteIdByName(spr_name));
 }
Beispiel #31
0
 /// <summary>
 /// Get sprite id by name
 /// </summary>
 /// <param name="name">the sprite name to ask</param>
 /// <returns></returns>
 public int GetSpriteIdByName(string name)
 {
     return(sprite.GetSpriteIdByName(name));
 }
Beispiel #32
0
    // Use this for initialization
    void Start()
    {
        if (viewCamera == null)
        {
            // Find a camera parent
            Transform node = transform;
            while (node && node.camera == null)
            {
                node = node.parent;
            }
            if (node && node.camera != null)
            {
                viewCamera = node.camera;
            }

            // ...otherwise, use the main camera
            if (viewCamera == null)
            {
                viewCamera = Camera.main;
            }
        }

        sprite = GetComponent<tk2dSprite>();

        // Change this to use animated sprites if necessary
        // Same concept here, lookup Ids and call Play(xxx) instead of .spriteId = xxx
        buttonDownSpriteId = sprite.GetSpriteIdByName(buttonDownSprite);
        buttonUpSpriteId = sprite.GetSpriteIdByName(buttonUpSprite);
        buttonPressedSpriteId = sprite.GetSpriteIdByName(buttonPressedSprite);

        if (collider == null)
        {
            BoxCollider newCollider = gameObject.AddComponent<BoxCollider>();
            Vector3 colliderExtents = newCollider.extents;
            colliderExtents.z = 0.2f;
            newCollider.extents = colliderExtents;
        }
    }
 //子弹飞行过程
 public void flying()
 {
     bulletSprite.SetSprite(bulletSprite.GetSpriteIdByName("flying"));
     bulletAni.Play("flying");
 }
Beispiel #34
0
 void Handle_LanguageChanged(Language l)
 {
     //transform.localScale = SpriteNames[(int)GameMain.Singleton.BSSetting.LaguageUsing.Val];
     mSpr.spriteId = mSpr.GetSpriteIdByName(SpriteNames[(int)GameMain.Singleton.BSSetting.LaguageUsing.Val]);
 }
Beispiel #35
0
    // Use this for initialization
    void Start()
    {
        // If we're generating from a seed
        if (seedGenerate)
            Random.seed = _currentSeed;
        _currentSeed = Random.seed;
        Random.seed = _currentSeed;

        _instance = this;

        _inventory = (GameObject.Find("inventory") as GameObject).GetComponent<Inventory>();

        _audioSource = GetComponent<AudioSource>();

        _floorSprite = GetComponentInChildren<tk2dSprite>();

        _popupText = (Instantiate(popupTextPrefab) as GameObject).GetComponent<tk2dTextMesh>();
        _popupText.transform.parent = transform;
        _popupText.gameObject.SetActive(false);

        _piecesToRemove = new List<GridPiece>();
        _piecesToDestroy = new List<GridPiece>();

        _gridWidth = Globals.ROOM_WIDTH;
        _gridHeight = Globals.ROOM_HEIGHT;

        _currentGame = new ProcGame();

        _currentRoom = _currentGame.startRoom;
        _player = _currentGame.player;
        _floorSprite.spriteId = _floorSprite.GetSpriteIdByName(_currentRoom.floorTilesName);
        _gridPieces = _currentRoom.gridPieces;
        foreach (GridPiece piece in _gridPieces) {
            piece.gameObject.SetActive(true);
        }

        // Begin the game
        addPlayerText("Hungry....");
    }
Beispiel #36
0
 void Start()
 {
     _sprite = GetComponent <tk2dSprite>();
     _offID  = _sprite.GetSpriteIdByName("off");
     _onID   = _sprite.GetSpriteIdByName("on");
 }
Beispiel #37
0
    private IEnumerator ReceiveMoneyFromCustomer()
    {
        currentGamePlayState = GamePlayState.receiveMoney;

        if (cash_obj == null)
        {
            cash_obj = Instantiate(Resources.Load("Money/Cash", typeof(GameObject))) as GameObject;
            cash_obj.transform.position = new Vector3(0, 0, -5);
            cash_sprite = cash_obj.GetComponent<tk2dSprite>();

            if(currentCustomer.amount < 20) {
                cash_sprite.spriteId = cash_sprite.GetSpriteIdByName("cash_20");
                currentCustomer.payMoney = 20;
            }
            else if(currentCustomer.amount < 50) {
                cash_sprite.spriteId = cash_sprite.GetSpriteIdByName("cash_50");
                currentCustomer.payMoney = 50;
            }
            else if(currentCustomer.amount <= 100) {
                cash_sprite.spriteId = cash_sprite.GetSpriteIdByName("cash_100");
                currentCustomer.payMoney = 100;
            }
        }

        yield return new WaitForSeconds(3);

        Destroy(cash_obj.gameObject);
        calculator_group_instance.SetActiveRecursively(true);
        this.DeActiveCalculationPriceGUI();

        this.ShowGiveTheChangeForm();
        currentGamePlayState = GamePlayState.giveTheChange;

        if(MainMenu._HasNewGameEvent) {
            audioDescribe.PlayOnecSound(description_clips[6]);
        }
    }
Beispiel #38
0
    void Awake()
    {
        sceneController = GameObject.FindGameObjectWithTag("GameController").GetComponent<SheepBank>();

        topDonationButton_sprite = topDonateButton_Obj.GetComponent<tk2dSprite>();
        downDonationButton_sprite = downDonateButton_Obj.GetComponent<tk2dSprite>();
        //@!-- Find index of donation_button texture;
        activeDonationButton_id = topDonationButton_sprite.GetSpriteIdByName("Donate_button");
        unactiveDonationButton_id = topDonationButton_sprite.GetSpriteIdByName("Donate_button_unactive");
    }