Ejemplo n.º 1
0
    /**
     * Instantiates a tray before a Customer.
     */
    public void onClick(Customer customer)
    {
        if (customer.CurrentState == Customer.State.EMPTY_HANDED)
        {
            Transform customerTransform = customer.transform;
            Vector3   trayPosition      = customerTransform.position;

            trayPosition   += customerTransform.forward * TRAY_DISTANCE;
            trayPosition.y += TRAY_HEIGHT;

            customer.HeldItem     = Creatable.Create <Tray>(tray, trayPosition, customerTransform.rotation, customerTransform);
            customer.CurrentState = Customer.State.HOLDING_ITEM;
        }
    }
Ejemplo n.º 2
0
    /**
     * Hands the Customer a glass, if they're not holding anything already.
     *
     * <param name="customer">The Customer.</param>
     */
    public void onClick(Customer customer)
    {
        if (customer.CurrentState == Customer.State.EMPTY_HANDED)
        {
            Transform customerTransform = customer.transform;
            Vector3   glassPosition     = customerTransform.position;

            glassPosition   += customerTransform.forward * GLASS_DISTANCE;
            glassPosition.y += GLASS_HEIGHT;

            customer.HeldItem     = Creatable.Create <Cup>(glass, glassPosition, customerTransform.rotation, customerTransform);
            customer.CurrentState = Customer.State.HOLDING_ITEM;
        }
    }
Ejemplo n.º 3
0
        /// <summary>
        /// Generates a Creatable instance by using a definition
        /// contained in a node specified by an xpath.
        /// If the specified xpath gives more than one result,
        /// a Creatable is selected randomly.
        /// </summary>
        /// <param name="xpath">The xpath to the node
        /// containing the Creatable definition</param>
        /// <returns>The generated Creatable instance</returns>
        public Creatable Generate(string xpath)
        {
            XmlNodeList nodes = doc.SelectNodes(xpath);

            if (nodes.Count == 0)
            {
                throw new InvalidOperationException("No matching Creatable definition found in " + filename);
            }
            XmlElement prototype    = (XmlElement)nodes[Rng.Random.Next(nodes.Count)];
            string     typeName     = prototype.Attributes[TYPE_NAME].Value;
            string     assemblyName = prototype.Attributes[ASSEMBLY_NAME].Value;
            Assembly   assembly     = AssemblyCache.GetAssembly(Application.StartupPath + "/" + assemblyName);
            Creatable  creatable    = (Creatable)assembly.CreateInstance(typeName);

            creatable.Create(prototype);
            return(creatable);
        }
    /**
     * Adds a plate to the Customer's Tray, if one is held.
     *
     * <param name="customer">The Customer.</param>
     */
    public void onClick(Customer customer)
    {
        if (customer.CurrentState == Customer.State.HOLDING_ITEM &&
            customer.HeldItem is Tray)
        {
            Tray tray = (Tray)customer.HeldItem;

            Transform trayTransform = tray.transform;
            Vector3   aboveTray     = trayTransform.position + (Vector3.up * 0.3f) + (Vector3.back * .1f);

            Plate plateObject = Creatable.Create <Plate>(plate, aboveTray, trayTransform.rotation, trayTransform);

            // Prevent the Plate from interacting with the Player's collider when spawned/placed on the Tray.
            Physics.IgnoreCollision(plateObject.GetComponent <Collider>(), customer.GetComponent <Collider>());

            tray.addItem(plateObject.gameObject);
            plateObject.HeldTray = tray;
        }
    }