Exemple #1
0
    NavMeshObstacle navObstacle; //Obstacle for other agents

    //Handle objects interactions w/ Workshop
    //Return wether the object is taken from tavernkeeper
    public bool use(GameObject object_used)
    {
        if (status == "waiting" && currentMug is null) //No mug in hand
        {
            //TODO : Gérer Grabale qui ne sont pas des Mugs ?
            if (object_used != null && object_used.tag == "Grabable")
            {
                Mug mug = object_used.GetComponent <Mug>();
                if (mug != null && mug.content != null && mug.content.Type == order)
                {
                    status = "consuming";
                    // Debug.Log(gameObject.name+" "+status+" "+object_used.name+ " of "+mug.content.Type);
                    currentMug   = object_used;
                    consumeTimer = consumeTime;
                    mug.take();
                    return(true);
                }
                else
                {
                    Debug.Log(gameObject.name + " doesn't want that " + object_used.name + " - Request : " + order);
                    return(false);
                }
            }
            else
            {
                Debug.Log(gameObject.name + " doesn't want that " + object_used.name + " - Request : " + order);
                return(false);
            }
        }
        else
        {
            Debug.Log(gameObject.name + " already consumming " + currentMug.name);
            return(false);
        }
    }
    // Update is called once per frame
    void Update()
    {
        // if(currentMug!=null)
        //     Debug.Log(gameObject.name+" stock: "+stock.Count+ " - CurrentMug: "+currentMug.name+" (Dirty: "+currentMug.GetComponent<Mug>().dirty+")");
        //Set current mug if there's stock
        if (currentMug is null && stock.Count > 0)
        {
            currentMug = stock[0];
            stock.RemoveAt(0);

            Mug mug = currentMug.GetComponent <Mug>();
            if (mug.content != null)//Empty mug
            {
                mug.consume();
                prepTimer = 0.0f;
            }
            else if (!mug.dirty)//Mug already clean
            {
                prepTimer = prepTime;
            }

            if (UIPrepTimer != null) //Display UI prep timer
            {
                UIPrepTimer.SetValue(prepTimer / prepTime);
                // UIPrepTimer.DisplayIcon(false);
                UIPrepTimer.gameObject.SetActive(true);
            }
        }
    }
 public override void Awake()
 {
     base.Awake();
     water         = GameObject.Find("Water");
     waterMaterial = water.GetComponent <MeshRenderer>().material;
     sinkLocation  = GameObject.Find("SinkLocation").GetComponent <ItemLocation>();
     mug           = GameObject.Find("Mug").GetComponent <Mug>();
 }
Exemple #4
0
    // TODO: Takes drink and starts to gossips

    public void TakeOrder(Mug mug)
    {
        _mug = mug.transform;
        mug.transform.position = new Vector3(handPosition.position.x, handPosition.position.y, handPosition.position.z);
        mug.transform.rotation = handPosition.rotation;
        CancelInvoke("Unhandled");
        coll.enabled = false;
        Invoke("Served", 30f);
    }
Exemple #5
0
        static void Main(string[] args)
        {
            Phone phone = new ApplePhone();

            phone = new Sticker(phone);
            phone = new Mug(phone);
            phone.Print();

            Console.ReadKey();
        }
    } //Stock of product

    //Handle objects interactions w/ Workshop
    //Return wether the object is taken from tavernkeeper
    public override bool use(GameObject userObject)
    {
        if (userObject != null)
        {
            // Debug.Log(userObject.tag);
            //TODO : Gérer Grabable qui ne sont pas des mugs ?
            if (userObject.tag == "Grabable" && currentMug is null) //Try to stock Mug into workshop
            {
                Mug mug = userObject.GetComponent <Mug>();
                if (mug != null && mug.content is null && !mug.dirty && Stock > 0) //Mug clean & empty + remaining stock in workshop
                {
                    Debug.Log(userObject.name + " stocked in " + gameObject.name);
                    mug.take();
                    currentMug = userObject;

                    if (UIPrepTimer != null) //Display UI prep timer
                    {
                        prepTimer = 0.0f;
                        UIPrepTimer.SetValue(prepTimer / prepTime);
                        UIPrepTimer.DisplayIcon(product_sprite);
                        UIPrepTimer.gameObject.SetActive(true);
                    }

                    return(true); //Object taken
                }
                else
                {
                    Debug.Log(userObject.name + " cannot be filled with " + product_name + " -stock:" + Stock);
                }
            }
            else if (userObject.tag == "Player" && prepTimer < prepTime && currentMug != null) //Prepare currentMug
            {
                continueUse(userObject);
            }
            else if (userObject.tag == "Player" && prepTimer >= prepTime) //Give tavernkeeper currentMug if finished preparation
            {
                Tavernkeeper_controller player = userObject.GetComponent <Tavernkeeper_controller>();
                Mug mug = currentMug.GetComponent <Mug>();
                if (player != null && mug != null)
                {
                    Debug.Log(gameObject.name + " give " + currentMug.name + " filled with " + product_name + " to " + userObject.name);
                    //Fill mug
                    mug.fill(new Consumable(product_name, product_value, product_sprite));
                    Stock--;
                    UIPrepTimer.gameObject.SetActive(false); //Turn off UI prep timer

                    //Give mug
                    player.grab(currentMug);
                    currentMug = null;
                }
            }
        }
 public override void Load()
 {
     foreach (var mymug in mugs)
     {
         Mug     item = new Mug(mymug.displayName, "StoneworkRoseCafe/Mugs/Items/" + mymug.texturePath + "Item");
         MugTile tile = new MugTile(item, "StoneworkRoseCafe/Mugs/Tiles/" + mymug.texturePath + "Tile");
         AddTile(mymug.displayName, tile, "StoneworkRoseCafe/Mugs/Tiles/" + mymug.texturePath + "Tile");
         item.tile = tile.Type;
         MugIDs.Add(tile.Type);                 //add so we can get all the mugs later
         AddItem(mymug.displayName, item);
         tile.drop = item.item.type;
     }
 }
Exemple #8
0
 public Rogue()
 {
     heroTexture = Engine.Engine.GetTexture("Hero/RogueSprite");
     Hero.loadSprite();
     visible  = true;
     heroRole = Classes.Rogue;
     inventory.addItem(new Dagger(1, 1));
     baseHealth     = 225;
     healthPerLevel = 35;
     resetLevel();
     resetHealth();
     canDuelWield = true;
     abilities[0] = new Mug();
     abilities[1] = new Invisibility();
     Engine.Engine.Log(health.ToString());
 }
Exemple #9
0
 public Duelist()
 {
     heroTexture = Engine.Engine.GetTexture("Hero/Duelist");
     Hero.loadSprite();
     heroRole            = Classes.Duelist;
     baseHealth          = 275;
     healthPerLevel      = 35;
     requiredBranchLevel = 30;
     resetLevel();
     resetHealth();
     Enemies.Enemy.UpdateTargets(this);
     Enemies.BossEnemy.UpdateBossTargets(this);
     abilities[0] = new Mug();
     abilities[1] = new Invisibility();
     abilities[2] = new Parry();
     abilities[3] = new Eviscerate();
     Engine.Engine.Log(health.ToString());
 }
Exemple #10
0
 public Ranger()
 {
     heroTexture = Engine.Engine.GetTexture("Hero/Ranger");
     Hero.loadSprite();
     heroRole            = Classes.Ranger;
     baseHealth          = 350;
     healthPerLevel      = 35;
     requiredBranchLevel = 30;
     resetLevel();
     resetHealth();
     Enemies.Enemy.UpdateTargets(this);
     Enemies.BossEnemy.UpdateBossTargets(this);
     abilities[0] = new Mug();
     abilities[1] = new Invisibility();
     abilities[2] = new Volley();
     abilities[3] = new SteadyShot();
     Engine.Engine.Log(health.ToString());
 }
Exemple #11
0
 public Assassin()
 {
     heroTexture = Engine.Engine.GetTexture("Hero/Assassin");
     Hero.loadSprite();
     heroRole            = Classes.Assassin;
     baseHealth          = 450;
     healthPerLevel      = 35;
     requiredBranchLevel = int.MaxValue;
     resetLevel();
     resetHealth();
     abilities[0] = new Mug();
     abilities[1] = new Invisibility();
     abilities[2] = new Parry();
     abilities[3] = new Eviscerate();
     abilities[4] = new Assassinate();
     abilities[5] = new Poison();
     Enemies.Enemy.UpdateTargets(this);
     Enemies.BossEnemy.UpdateBossTargets(this);
 }
Exemple #12
0
 public Marksman()
 {
     heroTexture = Engine.Engine.GetTexture("Hero/Marksman");
     Hero.loadSprite();
     heroRole            = Classes.Marksman;
     baseHealth          = 400;
     healthPerLevel      = 55;
     canDuelWield        = true;
     requiredBranchLevel = int.MaxValue;
     resetLevel();
     resetHealth();
     abilities[0] = new Mug();
     abilities[1] = new Invisibility();
     abilities[2] = new Volley();
     abilities[3] = new SteadyShot();
     abilities[4] = new Vault();
     abilities[5] = new EagleEye();
     Enemies.Enemy.UpdateTargets(this);
     Enemies.BossEnemy.UpdateBossTargets(this);
 }
    List <GameObject> stock = new List <GameObject>(); //List of mug in workshop

    //Handle objects interactions w/ Workshop
    //Return wether the object is taken from tavernkeeper
    public override bool use(GameObject userObject)
    {
        if (userObject != null)
        {
            //TODO : Gérer grabable autre que Mug
            if (userObject.tag == "Grabable")
            {
                //Stock mug
                Mug mug = userObject.GetComponent <Mug>();
                if (mug != null)
                {
                    Debug.Log(userObject.name + " stocked in " + gameObject.name);
                    mug.take();
                    stock.Add(userObject);

                    return(true); //Object taken
                }
            }
            else if (userObject.tag == "Player" && prepTimer < prepTime && currentMug != null) //Prepare currentMug
            {
                continueUse(userObject);
            }
            else if (userObject.tag == "Player" && prepTimer >= prepTime && currentMug != null) //Give tavernkeeper currentMug if cleaned
            {
                Tavernkeeper_controller player = userObject.GetComponent <Tavernkeeper_controller>();
                Mug mug = currentMug.GetComponent <Mug>();
                if (player != null && mug != null)
                {
                    // Debug.Log(gameObject.name+" give "+currentMug.name+" to "+userObject.name);
                    //Clean mug
                    mug.dirty = false;
                    //Give mug
                    player.grab(currentMug);
                    currentMug = null;

                    UIPrepTimer.gameObject.SetActive(false); //Turn off UI prep timer
                }
            }
        }
        return(false);
    }
Exemple #14
0
        public void Run()
        {
            var input = "186524973";
            var dic = new Dictionary <int, Mug>();
            int i, j;
            Mug prev  = null;
            Mug first = null;

            foreach (var c in input)
            {
                var m = new Mug()
                {
                    val = (int)(c - '0')
                };
                if (prev != null)
                {
                    m.previous = prev;
                    prev.next  = m;
                }
                dic.Add((int)(c - '0'), m);
                prev = m;
                if (first == null)
                {
                    first = m;
                }
            }

            for (i = 10; i <= 1000000; i++)
            {
                var m = new Mug()
                {
                    val = i
                };
                if (prev != null)
                {
                    m.previous = prev;
                    prev.next  = m;
                }
                dic.Add(i, m);
                prev = m;
            }

            first.previous    = dic[1000000];
            dic[1000000].next = first;

            var current = first;

            for (i = 0; i < 10000000; i++)
            {
                Console.WriteLine(i);
                var dest = current.val - 1;
                if (dest < 1)
                {
                    dest = 1000000;
                }
                while (current.next.val == dest || current.next.next.val == dest || current.next.next.next.val == dest)
                {
                    dest--;
                    if (dest < 1)
                    {
                        dest = 1000000;
                    }
                }
                var destA = dic[dest];      // destination A
                var destB = dic[dest].next; // destination B
                var mug   = current;
                var a     = mug.next;
                var c     = mug.next.next.next;
                var d     = mug.next.next.next.next;

                var destANext = a;
                var aPrev     = destA;
                var destBPrev = c;
                var cNext     = destB;
                var mugNext   = d;
                var dPrev     = mug;

                destA.next     = destANext;
                a.previous     = aPrev;
                destB.previous = destBPrev;
                c.next         = cNext;
                mug.next       = mugNext;
                d.previous     = dPrev;

                current = d;
            }

            Console.WriteLine(dic[1].next.val + " " + dic[1].next.next.val);
            Console.WriteLine(((ulong)dic[1].next.val * (ulong)dic[1].next.next.val));

            Console.ReadLine();
            Console.WriteLine("DONE");
            Console.ReadLine();
        }
Exemple #15
0
 public DrinkPreference(IEnumerable <IngredientAmount> amounts, Mug mug)
 {
     Amounts = amounts;
     Mug     = mug;
 }
Exemple #16
0
    // Update is called once per frame
    protected virtual void Update()
    {
        //Update status if it was requested
        if (_lastStatusRequest != null)
        {
            _prevStatus = _status;
            _status     = _lastStatusRequest;

            animator.SetTrigger(_status); //Update status in animator
            updateStatus(_status);

            _lastStatusRequest = null;

            // Debug.Log(gameObject.name+" "+_status);
        }

        //Navigation
        // Debug.Log(gameObject.name + " navigation : "+ agent.isStopped + " " + agent.remainingDistance);
        Debug.DrawLine(gameObject.transform.position, agent.destination, Color.blue, 0.0f);


        if (status == "entering" && !agent.pathPending && agent.remainingDistance == 0) //Reached seat ?
        {
            status    = "waiting";
            waitTimer = waitingTime;
            order     = ClientManager.Instance.assignOrder();
            if (UIWaitingTimer != null) //Update UI Waiting timer Icon
            {
                UIWaitingTimer.DisplayIcon(StockManager.Instance.consumableSprite(order));
            }
        }

        else if (status == "waiting")
        {
            waitTimer -= Time.deltaTime;
            if (waitTimer < 0) //Waited too long
            {
                //Leave tavern
                status           = "leaving";
                currentObjective = assigedPos = ClientManager.Instance.assignTarget(assigedPos, true); //Assign leaving target and set it as current objective
            }
            else if (UIWaitingTimer != null)                                                           //Update UI Waiting timer
            {
                UIWaitingTimer.SetValue(waitTimer / waitingTime);
            }
        }

        //Consume Timer
        else if (status == "consuming") //Consuming mug if there's one and reached destination
        {
            consumeTimer -= Time.deltaTime;
            if (consumeTimer < 0) //Finished consuming mug ?
            {
                Mug obj = currentMug.GetComponent <Mug>();
                if (obj != null)
                {
                    //Reward
                    Consumable content = obj.consume();
                    int        money   = (int)(content.Value * (1.0f + waitTimer / waitingTime)); //Reward = value order +  Tips (value * waitTime)
                    ClientManager.Instance.clientReward(money);

                    //Drop mug
                    Transform dropPos = gameObject.transform;
                    dropPos.position += (Vector3)Vector2.down * 0.2f;
                    obj.drop(dropPos);
                    currentMug = null;
                }

                //Leave tavern
                status           = "leaving";
                currentObjective = assigedPos = ClientManager.Instance.assignTarget(assigedPos, true); //Assign leaving target and set it as current objective
            }
        }

        else if (status == "leaving" && !agent.pathPending && agent.remainingDistance < 0.5) //Reached exit ?
        {
            Destroy(gameObject);
        }

        else if (status == "event" && !agent.pathPending && agent.remainingDistance == 0) //Reached event ?
        {
            assignToEvent();                                                              //In case events already finished, come back to normal
        }
    }
Exemple #17
0
 public DrinkRequest(IEnumerable <Ingredient> ingredients, Mug mug)
 {
     Ingredients = ingredients;
     Mug         = mug;
 }