Exemplo n.º 1
0
 public void Release(OwnerScript owned)
 {
     if (this == owned.owner)
     {
         mySupply -= owned.supply;
         myDemand -= owned.demand;
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// Calls this function with the specified args
 /// </summary>
 /// <param name="args">The arguments (count > 0) to pass to the function. (Argument 0 MUST be empty!)</param>
 /// <returns></returns>
 /// <exception cref="System.ArgumentException">Thrown if function is not of DataType.Function</exception>
 public DynValue Call(IList <DynValue> args)
 {
     if (!isAlive)
     {
         throw new InvalidOperationException(string.Format("Attempting to Call on dead Closure"));
     }
     return(OwnerScript.Call(DynValue.NewClosure(this), args));
 }
Exemplo n.º 3
0
        /// <summary>
        /// Evaluates the expression
        /// </summary>
        /// <param name="context">The context.</param>
        /// <returns></returns>
        public DynValue Evaluate(ScriptExecutionContext context = null)
        {
            context = context ?? OwnerScript.CreateDynamicExecutionContext();

            if (m_Constant != null)
            {
                return(m_Constant);
            }

            return(m_Exp.Eval(context));
        }
		/// <summary>
		/// Evaluates the expression
		/// </summary>
		/// <param name="context">The context.</param>
		/// <returns></returns>
		public DynValue Evaluate(ScriptExecutionContext context = null)
		{
			context = context ?? OwnerScript.CreateDynamicExecutionContext();

			this.CheckScriptOwnership(context.GetScript());

			if (m_Constant != null)
				return m_Constant;

			return m_Exp.Eval(context);
		}
        /// <summary>
        /// Update active shepherd and move selection frame in UI
        /// </summary>
        /// <param name="owner">New active shepherd id</param>

        /// <summary>
        /// Initialize the current level (based on m_levelCounter)
        /// </summary>
        public void InitLevel()
        {
            // clear the previous level and set all variables to their
            // original value
            foreach (var sheep in m_sheep)
            {
                Destroy(sheep);
            }
            foreach (var shepherd in m_shepherds)
            {
                Destroy(shepherd);
            }

            m_sheep.Clear();
            SetActiveShepherd(0);
            continueButton.SetActive(false);
            shepherdLocs = new Dictionary <Vector2, int>();

            // Load level
            ShepherdLevel level;

            if (m_endlessMode)
            {
                // Create randomly generated level
                level = CreateEndlessLevel(m_levelCounter);
            }
            else
            {
                // Use premade level
                level = m_levels[m_levelCounter];
            }

            // Update shepherd budget
            budget = level.ShepherdBudget;

            // Add all sheep from level
            for (int i = 0; i < level.SheepList.Count; i++)
            {
                var            sheep = level.SheepList[i];
                var            type  = level.SheepTypes[i];
                var            pos   = new Vector3(sheep.x, sheep.y, -1);
                var            obj   = Instantiate(m_sheepPrefab, pos, Quaternion.identity) as GameObject;
                SpriteRenderer sr    = obj.GetComponent <SpriteRenderer>();
                OwnerScript    os    = obj.GetComponent <OwnerScript>();
                sr.color = Colors[type];
                os.SetOwner(type);
                m_sheep.Add(obj);
            }

            // Update Voronoi
            StartVoronoi();
            UpdateMesh();
            UpdateText(m_sheep.Count);
        }
Exemplo n.º 6
0
    public override void Use()
    {
        if (useIsAllowed)
        {
            base.Use();

            Rumble();

            GameObject wall = Instantiate(wallPrefab);
            BasePlayer p    = OwnerScript.GetComponent <BasePlayer>();
            p.name = "PantomimeWall";

            wall.transform.position = transform.position + transform.forward * 2f;
            wall.transform.rotation = transform.rotation;

            useIsAllowed = false;
            StartCoroutine(WaitForNextAbility());
        }
    }
Exemplo n.º 7
0
    //registering units with a player costs the player supply
    public bool Register(OwnerScript owned, int demand = 0, int supply = 0)
    {
        //if player hasn't enough supply
        if (demand > mySupply - myDemand)
        {
            owned.Own(null, demand, supply);

            Debug.Log(this + " can't afford " + demand + " supply.");

            return(false);
        }

        //otherwise, proceed
        owned.Own(this, demand, supply);

        myDemand += demand;
        mySupply += supply;

        return(true);
    }
Exemplo n.º 8
0
    public override void Use()
    {
        if (useIsAllowed)
        {
            if (GameObject.FindGameObjectWithTag("Pie") == null)
            {
                base.Use();


                Rumble();

                GameObject obj = Instantiate(piePrefab);

                BasePlayer   p   = OwnerScript.GetComponent <BasePlayer>();
                PieBehaviour pie = obj.GetComponent <PieBehaviour>();

                pie.OwnerScript   = this.OwnerScript;
                pie.PlayerActions = p.PlayerActions;
                pie.RumbleManager = p.RumbleManager;

                obj.transform.position = transform.position - transform.forward * 1.5f;
                obj.transform.rotation = transform.rotation;

                useIsAllowed = false;

                StartCoroutine(WaitForNextAbility());
            }
            else
            {
                BasePlayer player = OwnerScript.GetComponent <BasePlayer>();

                if (player != null)
                {
                    player.Energy += EnergyCost;
                }
            }
        }
    }
Exemplo n.º 9
0
    void Awake()
    {
        myNavMeshAgent = GetComponent <NavMeshAgent>();

        if (null == myOwner)
        {
            myOwner = GetComponent <OwnerScript>();
        }

        if (null == myHealth)
        {
            myHealth = GetComponent <HealthScript>();
        }

        if (null == myCommands)
        {
            myCommands = GetComponent <CommandScript>();
        }

        if (null == myAttackMessenger)
        {
            myAttackMessenger = gameObject.AddComponent <Messenger_Script>() as Messenger_Script;
        }
    }
Exemplo n.º 10
0
 public void Release(OwnerScript owned)
 {
     if (this == owned.owner)
     {
         mySupply -= owned.supply;
         myDemand -= owned.demand;
     }
 }
Exemplo n.º 11
0
 public Task <DynValue> CallAsync()
 {
     return(OwnerScript.CallAsync(this));
 }
Exemplo n.º 12
0
    //registering units with a player costs the player supply
    public bool Register(OwnerScript owned, int demand = 0, int supply = 0)
    {
        //if player hasn't enough supply
        if(demand > mySupply - myDemand)
        {
            owned.Own(null, demand, supply);

            Debug.Log(this + " can't afford " + demand + " supply.");

            return false;
        }

        //otherwise, proceed
        owned.Own(this, demand, supply);

        myDemand += demand;
        mySupply += supply;

        return true;
    }
Exemplo n.º 13
0
 public Task <DynValue> CallAsync(params DynValue[] args)
 {
     return(OwnerScript.CallAsync(this, args));
 }
Exemplo n.º 14
0
 /// <summary>
 /// Calls this function with the specified args
 /// </summary>
 /// <returns></returns>
 /// <exception cref="System.ArgumentException">Thrown if function is not of DataType.Function</exception>
 public DynValue Call()
 {
     return(OwnerScript.Call(this));
 }
Exemplo n.º 15
0
 /// <summary>
 /// Calls this function with the specified args
 /// </summary>
 /// <param name="args">The arguments to pass to the function.</param>
 /// <returns></returns>
 /// <exception cref="System.ArgumentException">Thrown if function is not of DataType.Function</exception>
 public DynValue Call(params DynValue[] args)
 {
     return(OwnerScript.Call(this, args));
 }
Exemplo n.º 16
0
 public DynValue Evaluate()
 {
     return(Evaluate(OwnerScript.CreateDynamicExecutionContext()));
 }
Exemplo n.º 17
0
 /// <summary>
 /// Asynchronously calls this function with the specified args
 ///
 /// This method is supported only on .NET 4.x and .NET 4.x PCL targets.
 /// </summary>
 /// <param name="function">The function.</param>
 /// <param name="args">The arguments to pass to the function.</param>
 /// <returns></returns>
 /// <exception cref="System.ArgumentException">Thrown if function is not of DataType.Function</exception>
 public Task <DynValue> CallAsync(ExecutionControlToken ecToken, params DynValue[] args)
 {
     return(OwnerScript.CallAsync(ecToken, this, args));
 }
Exemplo n.º 18
0
    void Awake()
    {
        myNavMeshAgent = GetComponent<NavMeshAgent>();

        if(null == myOwner)
        {
            myOwner = GetComponent<OwnerScript>();
        }

        if(null == myHealth)
        {
            myHealth = GetComponent<HealthScript>();
        }

        if(null == myCommands)
        {
            myCommands = GetComponent<CommandScript>();
        }

        if(null == myAttackMessenger)
        {
            myAttackMessenger = gameObject.AddComponent<Messenger_Script>() as Messenger_Script;
        }
    }
Exemplo n.º 19
0
 /// <summary>
 /// Asynchronously calls this function with the specified args
 ///
 /// This method is supported only on .NET 4.x and .NET 4.x PCL targets.
 /// </summary>
 /// <param name="function">The function.</param>
 /// <returns></returns>
 /// <exception cref="System.ArgumentException">Thrown if function is not of DataType.Function</exception>
 public Task <DynValue> CallAsync(ExecutionControlToken ecToken)
 {
     return(OwnerScript.CallAsync(ecToken, this));
 }