Example #1
0
    public void Update()
    {
        float money = BabySmileManager.GetMoney();

        temMoney  = Mathf.Lerp(temMoney, money, smooth * Time.deltaTime);
        data.text = Mathf.Round(temMoney).ToString();
    }
Example #2
0
    void Update()
    {
        //花盆状态 生苗1枯苗2生花3枯花4成花5
        int itemid     = GetComponent <SceneItem>().id;
        int flowerStat = BabySmileManager.GetItemState(itemid);
        int placeid    = BabySmileManager.GetTableType(BabySmileManager.GetItemTableID(itemid));

        /*
         * if (flowerStat == 2 || flowerStat == 4 || flowerStat == 5)
         * {
         *  //枯苗和枯花和成花都是锁定在阳台上不可拾取的,只能对其进行浇水或者采摘操作
         *  //BabySmileManager.SetPickable(itemid, false);
         * }*/
        if (placeid == 3 && (flowerStat == 1 || flowerStat == 3))
        {
            //生苗和生花可以拾取,但只有在阳台才会生长
            acumTime += Time.deltaTime;
            if (acumTime > waterTime)
            {
                acumTime = 0;
                //BabySmileManager.SetPickable(itemid, true);
                BabySmileManager.SetItemState(itemid, flowerStat + 1);
                //表现层改状态为枯苗/枯花
                SceneControl.Instance.InteractItems[itemid].GetComponent <SceneItem>().Status = flowerStat + 1;
            }
        }
    }
Example #3
0
    void Update()
    {
        int itemid = GetComponent <SceneItem>().id;
        int pcStat = BabySmileManager.GetItemState(itemid);

        if (pcStat == 1)
        {
            //随机产生邮件
            acumTime += Time.deltaTime;
            waitTime  = 0;
            if (acumTime > jobTh)
            {
                acumTime = 0;
                jobTh    = Random.Range(minTime, maxTime);
                BabySmileManager.SetItemState(itemid, 2);
                //表现层改状态为邮件
                SceneControl.Instance.InteractItems[itemid].GetComponent <SceneItem>().Status = 2;
                OnShowJob();
            }
        }
        else if (pcStat == 2)
        {
            //长时间没人理会变成关机
            waitTime += Time.deltaTime;
            if (waitTime > waitTh)
            {
                waitTime = 0;
                BabySmileManager.SetItemState(itemid, 1);
                //表现层改状态为关机

                SceneControl.Instance.InteractItems[itemid].GetComponent <SceneItem>().Status = 1;
                OnEndJob();
            }
        }
    }
Example #4
0
    public void Update()
    {
        float health = BabySmileManager.GetHealthRate();

        temHealth        = Mathf.Lerp(temHealth, health, smooth * Time.deltaTime);
        image.fillAmount = temHealth;
    }
Example #5
0
        public void PlayerInteractHold(GameObject player, int target, bool enable)
        {
            Debug.Log($"CharacterHold:{enable} - {player.name}");

            int role = player.GetComponent <CharacterControl>().roleId;

            if (enable)
            {
                var commands = BabySmileManager.InteractItem(role, target);
                foreach (var(cmd, data) in commands)
                {
                    if (cmd == (int)DataCommand.StartCast)
                    {
                        PlayerStartCast(player, target, data);
                    }
                }
            }
            else
            {
                var item = InteractItems[target].GetComponent <SceneItem>();
                if (!item.HasTimerRunning)
                {
                    var commands = BabySmileManager.MissionComplete(role, target);
                    foreach (var(cmd, data) in commands)
                    {
                        ProcessCmd(cmd, player, target, data);
                    }
                }
                item.ClearTimer();
            }
        }
Example #6
0
        private void SceneUpdateItemStatus(int itemId)
        {
            int status = BabySmileManager.GetItemState(itemId);
            var go     = SceneControl.Instance.InteractItems[itemId];
            var item   = go.GetComponent <SceneItem>();

            item.Status = status;
        }
Example #7
0
    void Start()
    {
        //游戏开始就要有个工作出现
        int itemid = GetComponent <SceneItem>().id;

        jobTh = Random.Range(minTime, maxTime);
        BabySmileManager.SetItemState(itemid, 2);
        //表现层改状态为邮件
        SceneControl.Instance.InteractItems[itemid].GetComponent <SceneItem>().Status = 2;
    }
Example #8
0
    void Update()
    {
        int itemid   = GetComponent <SceneItem>().id;
        int babyStat = BabySmileManager.GetItemState(itemid);

        if (babyStat == 1)
        {
            //平静
            acumTime += Time.deltaTime;
            if (acumTime > cryTh)
            {
                //提需求,开始哭
                acumTime = 0;
                cryTh    = Random.Range(minTime, maxTime);

                int taskType = Random.Range(1, taskNum + 1);

                if (m_state == State.FirstTask)
                {
                    taskType = 2;
                    m_state  = State.SecondTask;
                    FirstTutorial.ShowFor(8f);
                }
                else if (m_state == State.SecondTask)
                {
                    taskType = 1;
                    m_state  = State.RandomTask;
                    SecondTutorial.ShowFor(8f);
                }
                else if (m_state == State.RandomTask)
                {
                    // do nothing
                }

                BabySmileManager.AddTask(taskType);
                BabySmileManager.SetItemState(itemid, 2);

                OnStartTask(taskType);
                SceneControl.Instance.InteractItems[itemid].GetComponent <SceneItem>().Status = 2;
            }
        }
        else
        {
            //婴儿在哭
            cryTime += Time.deltaTime;
            if (cryTime > hurtTh)
            {
                cryTime = 0;
                BabySmileManager.ChangeHealth(-1);
                //表现层健康条减小
            }
        }
    }
Example #9
0
        public Tuple <int, SceneItemType> UpdateInteractTarget(GameObject player)
        {
            var component = player.transform.Find("InteractTrigger").GetComponent <CharacterTriggerInteract>();

            var item  = component.GetNearestItem(player)?.GetComponent <SceneItem>();
            var table = component.GetNearestTable(player)?.GetComponent <SceneItem>();

            SceneItem target = null;

            if (table != null && item != null)
            {
                int itemOnTable = BabySmileManager.GetTableItemID(table.id);
                target = itemOnTable == item.id ? item : table;
            }
            else if (table != null)
            {
                target = table;
            }
            else if (item != null)
            {
                target = item;
            }

            var character = player.GetComponent <CharacterControl>();
            int prevId    = character.InteractTarget;
            var prevType  = character.InteractType;
            var dict      = prevType == SceneItemType.Item ? InteractItems : InteractTables;
            var prevObj   = dict.ContainsKey(prevId) ? dict[prevId] : null;
            var prevItem  = prevObj != null?prevObj.GetComponent <SceneItem>() : null;

            if (target != prevItem)
            {
                if (target != null)
                {
                    target.SetInteract(true);
                }

                if (prevItem != null)
                {
                    prevItem.SetInteract(false);
                }

                return(target == null
                    ? new Tuple <int, SceneItemType>(0, SceneItemType.Item)
                    : new Tuple <int, SceneItemType>(target.id, target.type));
            }

            return(new Tuple <int, SceneItemType>(prevId, prevType));
        }
Example #10
0
    void Update()
    {
        int itemid = GetComponent <SceneItem>().id;

        if (price > BabySmileManager.GetMoney())
        {
            BabySmileManager.SetItemState(itemid, 1);
            //表现层改状态为缺货
            GetComponent <SceneItem>().Status = 1;
        }
        else
        {
            BabySmileManager.SetItemState(itemid, 2);
            //表现层改状态为有货
            GetComponent <SceneItem>().Status = 2;
        }
    }
Example #11
0
        public void PlayerInteractTap(GameObject player, int target, SceneItemType type)
        {
            Debug.Log($"CharacterTap - {player.name}, {target}");
            int role = player.GetComponent <CharacterControl>().roleId;

            var commands = type == SceneItemType.Table
                ? BabySmileManager.InteractTable(role, target)
                : BabySmileManager.InteractItem(role, target);

            foreach (var(cmd, data) in commands)
            {
                if (cmd != (int)DataCommand.StartCast)
                {
                    ProcessCmd(cmd, player, target, data);
                }
            }
        }