Пример #1
0
 //private Vector2 n_pos;
 // Use this for initialization
 void Start()
 {
     player_action = gameObject.GetComponent<ActionScript>();
     cur_way = 0;
     speed_x = 0;
     //n_pos = gameObject.transform.position;
 }
Пример #2
0
 void Update()
 {
     if ((DogController.Instance.transform.position - transform.position).magnitude < Radius)
     {
         renderer.color = Color.green;
         ActionScript actionScript = GetComponent <ActionScript>();
         if (Input.GetKeyDown(KeyCode.Space))
         {
             if (DogBehaviour.Instance.CurrentAction == action)
             {
                 DogBehaviour.Instance.UnsetAction();
                 if (actionScript != null)
                 {
                     actionScript.CleanAction();
                 }
             }
             else
             {
                 DogBehaviour.Instance.SetAction(action, transform.position);
                 if (actionScript != null)
                 {
                     actionScript.PerformAction();
                 }
             }
         }
     }
     else
     {
         renderer.color = Color.white;
     }
 }
Пример #3
0
 private void OnTriggerEnter2D(Collider2D other)
 {
     //if(!isTaken)Debug.Log(other.gameObject + " enter");
     if (!isTaken)
     {
         string tag = other.gameObject.tag;
         if (tag == "Player" || tag == "Clone")
         {
             cosmonaut = other.gameObject.GetComponent <ActionScript>();
             if (tag == "Player")
             {
                 cosmonaut.transform.Find("Text").gameObject.SetActive(true);
             }
             if (cosmonaut.getBox() == null)
             {
                 cosmonaut.setBox(transform.gameObject);
             }
             //isActivity = true;
         }
         else
         {
             if (tag == "Boxtaker")
             {
                 cosmonaut = other.GetComponentInParent <ActionScript>();
             }
         }
     }
 }
Пример #4
0
    public void Play()
    {
        if (_runManaAction != null)
        {
            _runManaAction.Stop(true);
            _runManaAction = null;
        }

        // Play sound
        SoundManager.PlayButtonOpen();

        // Double check if enough mana
        // Dont check mana
        //if (_userData.Mana > 0)
        {
            // Stop top friends
            _topFriends.Stop();

            // Hide Map Info popup
            _mapInfoPopup.Hide();

            // Decrease mana
            NotificationManager.ManaChanged(_userData.Mana - 1);

            // Go to main game
            GoToMainGame();
        }
    }
Пример #5
0
    void OnBuyManaCallback()
    {
        if (_userData.Mana < Settings.MaxMana)
        {
            // Play sound
            SoundManager.Instance.PlaySound(SoundID.Coin);

            // Decrease coin
            NotificationManager.CoinChanged(_userData.Coin - Settings.CoinToBuyFullMana);

            float duration = (Settings.MaxMana - _userData.Mana) / 20.0f;

            var action = LerpIntAction.Create(_userData.Mana, Settings.MaxMana, duration, (mana) => {
                NotificationManager.ManaChanged(mana);
            });

            _runManaAction = gameObject.Play(action, () => {
                _runManaAction = null;
            });
        }
        else
        {
            //Log.Debug("Full Mana!");
        }
    }
    /// <summary>
    /// Tween a 'public' property of the tween's owner object
    /// </summary>
    /// <param name="var">Property name</param>
    /// <param name="fromValue">From value</param>
    /// <param name="toValue">To value</param>
    /// <param name="easing">Easing function</param>
    /// <param name="pongEasing">Easing when 'ponging'</param>
    /// <returns>Tween object</returns>
    public OTTween Tween(string var, object fromValue, object toValue, OTEase easing, OTEase pongEasing)
    {
        vars.Add(var);
        SetVar(var);
        if (fromValue != null)
        {
            object fv = fromValues[fromValues.Count - 1];
            if (fv != null)
            {
#if UNITY_FLASH
                if (fv is float && fromValue is int)
                {
                    ActionScript.Statement("$fromValue = Number($fromValue);");
                }
#else
                if (fv is float && fromValue is int)
                {
                    fromValue = System.Convert.ToSingle(fromValue);
                }
                else
                if (fv is double && fromValue is int)
                {
                    fromValue = System.Convert.ToDouble(fromValue);
                }
#endif
            }
            fromValues[fromValues.Count - 1] = fromValue;
        }
        toValues.Add(toValue);
        easings.Add(easing);
        pongEasings.Add(pongEasing);
        return(this);
    }
Пример #7
0
        internal static void ReadVars(DataStream stream, ref Dictionary <string, object> vars)
        {
            stream.Stream.Seek(1, SeekOrigin.Current); // skip type mark

            if (ActionScript.ReadString(stream) != MARKER)
            {
                throw new InvalidOperationException("Invalid metadata marker");
            }

            // global object type
            KnownTypes type = (KnownTypes)stream.ReadByte();

            switch (type)
            {
            case KnownTypes.MixedArray:
                vars = ActionScript.ReadMixedArray(stream);
                break;

            case KnownTypes.Object:
                vars = ActionScript.ReadObject(stream);
                break;

            default:
                throw new InvalidOperationException("Invalid or unsupported root object data type: " + type);
            }
        }
Пример #8
0
    public static void AddUnit(ActionScript unit)
    {
        //Debug.Log(units["player"].Count);
        Debug.Log("Hola");
        List <ActionScript> list;

        if (!units.ContainsKey(unit.tag))
        {
            Debug.Log("adios");
            list            = new List <ActionScript>();
            units[unit.tag] = list;

            if (!turnKey.Contains(unit.tag))
            {
                turnKey.Enqueue(unit.tag);
            }
        }
        else
        {
            list = units[unit.tag];
            Debug.Log("che");
        }

        list.Add(unit);
    }
Пример #9
0
    //float moveSpeed;


    void Start()
    {
        Spawn();
        touched = gameObject.GetComponent <ActionScript>();


        hp = Random.Range(2, 15);
    }
Пример #10
0
    public static void Play(this GameObject go, BaseAction action, Action callback = null, bool isSelfDestroy = true)
    {
        // Add action script
        ActionScript actionScript = go.AddComponent <ActionScript>();

        // Play action
        actionScript.Play(action, callback, isSelfDestroy);
    }
Пример #11
0
        private IEnumerator RunActionScript(Entity actor)
        {
            yield return(new WaitForSeconds(ActivationDelay));

            ActionScript.Run(actor);
            AfterAction(actor);
            Ready = true;
        }
Пример #12
0
    public static void StopAction(this GameObject go, bool forceEnd = false)
    {
        ActionScript actionScript = go.GetComponent <ActionScript>();

        if (actionScript != null)
        {
            actionScript.Stop(forceEnd);
        }
    }
Пример #13
0
    public static void ReplayAction(this GameObject go)
    {
        ActionScript actionScript = go.GetComponent <ActionScript>();

        if (actionScript != null)
        {
            actionScript.Replay();
        }
    }
Пример #14
0
    public static void ResumeAction(this GameObject go)
    {
        ActionScript actionScript = go.GetComponent <ActionScript>();

        if (actionScript != null)
        {
            actionScript.Paused = false;
        }
    }
Пример #15
0
    /**
     * Compare function ptrs.
     *
     * Due to delegate wrapping in AS3 it is not possible to compare events in JS.
     **/
    public bool compareToDelegate(EventDelegate delegateObj, EventDispatcher.EventCallback delegateCallback, bool useCapture)
    {
#if UNITY_EDITOR
        if (delegateObj.delegateCallback == delegateCallback)
#else
        if (ActionScript.Expression <bool>("({0} == {1})", delegateObj.delegateCallback, delegateCallback))
#endif
        {
            return(true);
        }


#if UNITY_EDITOR
        // Fast check
        if (delegateObj.delegateCallback.GetHashCode() == delegateCallback.GetHashCode() && delegateObj.useCapture == useCapture)
        {
            return(true);
        }

        MulticastDelegate internalDelegate = cacheCompilerGenerated(delegateObj.delegateCallback);

        // Handle compilter genreated
        MulticastDelegate dOther = delegateCallback;
        if (dOther != null && internalDelegate != null && dOther.Target != null)
        {
            System.Object dTargetOther = (System.Object)dOther.Target;


            FieldInfo[] attrsB = dTargetOther.GetType().GetFields(BindingFlags.NonPublic | BindingFlags.Instance);

            if (attrsB.Length > 0)
            {
                if (attrsB[0].Name[0] == '$')
                {
                    // Get as deledages
                    MulticastDelegate B = attrsB[0].GetValue(dTargetOther) as MulticastDelegate;

                    // Compare delegates
                    bool cmp = internalDelegate == B;

                    Debug.LogWarning("Event arg declared on " + B.Method.Name + ":" + B.Target + " must be CEvent, please refactor events for Flash player builds");

                    // Return
                    return(cmp && delegateObj.useCapture == useCapture);
                }
            }
        }

        bool cmpB = delegateCallback == delegateObj.delegateCallback;

        // Default
        return(cmpB && delegateObj.useCapture == useCapture);
#else
        return(false);
#endif
    }
Пример #16
0
    void Start()
    {
        syncPos = transform.position;
        inputSyncTimer = inputSyncDelay;

        mainAction = GetComponentInChildren<ActionScript>();

        if(!isServer)
            GetComponent<Rigidbody>().useGravity = false;
    }
 private void Start()
 {
     Cursor.lockState = CursorLockMode.Locked;
     Cursor.visible   = false;
     actionscript     = GameObject.Find("Camera").GetComponent <ActionScript>();
     pause_ui         = GameObject.Find("Camera/Canvas/Pause");
     GameObject.Find("Camera/Canvas/Pause/Buttons/Resume").GetComponent <Button>().onClick.AddListener(Resume);
     GameObject.Find("Camera/Canvas/Pause/Buttons/Exit").GetComponent <Button>().onClick.AddListener(Exit);
     pause_ui.SetActive(false);
 }
Пример #18
0
        private void DoSelect()
        {
            ActionScript.CSL().WhenIndex += 1;

            BaseOverworldScreen oS = (BaseOverworldScreen)Core.CurrentScreen;

            oS.ActionScript.Switch(ScriptVersion2.ScriptComparer.EvaluateConstruct(Value));

            this.IsReady = true;
        }
Пример #19
0
    protected void Setup()
    {
        m_moveControl = GetComponent <GridMovementController>();
        stats         = GetComponent <Stats>();
        ActionScript moveAction = gameObject.AddComponent(typeof(ActionScript)) as ActionScript;

        moveAction.action = new UnityEngine.Events.UnityEvent();
        moveAction.action.AddListener(MoveClick);
        moveAction.actionImage = moveActionImage;
        skills.Add(moveAction);
    }
    static bool IsSubclassOf(Type a, Type b)
    {
#if !WORKAROUND
        /*
         * Temp/StagingArea/Data/ConvertedDotNetCode/global/TypeIsSubclass.as(20): col: 14 Error: Call to a possibly undefined method _Type_IsSubclassOf_Type through a reference with static type System:Type.
         */
        return(b.IsSubclassOf(a));
#else
        return(ActionScript.Expression <bool>("$b.Type_IsSubclassOf_Type($a)"));
#endif
    }
Пример #21
0
    void Start()
    {
        cat = GetComponent <CatScript>();


        catActions[(int)CatActions.Resting]   = gameObject.AddComponent <RestingActionScript>();
        catActions[(int)CatActions.Milling]   = gameObject.AddComponent <MillingActionsScript>();
        catActions[(int)CatActions.Pouncing]  = gameObject.AddComponent <PouncingActionScript>();
        catActions[(int)CatActions.Sprinting] = gameObject.AddComponent <CatVision>();
        currentAction = catActions[(int)CatActions.Milling];
    }
Пример #22
0
 void Start()
 {
     cosmonaut            = transform.Find("cosmonaut").transform;
     actionScript         = transform.GetComponent <ActionScript>();
     history              = new List <HistoryElement>();
     startPosition        = transform.position;
     rb                   = GetComponent <Rigidbody2D>();
     checkGrounded        = GetComponentInChildren <CheckGroundedScript>();
     checkCollidersScript = GetComponentInChildren <CheckCollidersScript>();
     remPoint             = GameObject.FindGameObjectWithTag("RememberPoint").GetComponent <rememberPointScript>();
     animator             = GetComponentInChildren <Animator>();
 }
Пример #23
0
        private void DoIf()
        {
            bool T = CheckCondition();

            ActionScript.CSL().WaitingEndIf[ActionScript.CSL().IfIndex + 1]   = false;
            ActionScript.CSL().CanTriggerElse[ActionScript.CSL().IfIndex + 1] = false;

            BaseOverworldScreen oS = (BaseOverworldScreen)Core.CurrentScreen;

            oS.ActionScript.ChooseIf(T);

            this.IsReady = true;
        }
Пример #24
0
 // Start is called before the first frame update
 void Start()
 {
     actionScript = transform.GetComponent <ActionScript>();
     iteration    = 0;
     if (history == null)
     {
         history = new List <HistoryElement>();
     }
     checkCollidersScript = GetComponentInChildren <CheckCollidersScript>();
     cosmonaut            = transform.Find("cosmonaut").transform;
     camera   = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <CameraScript>();
     animator = GetComponentInChildren <Animator>();
 }
Пример #25
0
    private void FixedUpdate()
    {
        //TODO check if action is currently locked. if not randomly select an action and perform
        if (!actionLocked)
        {
            //TODO update weights

            UpdateWeights();

            currentAction = catActions[Choose(ActionWeights)];
        }

        currentAction.Act();
    }
Пример #26
0
        private void ResetStartTicks()
        {
#if UNITY_FLASH && !UNITY_EDITOR
            ticksOnStart           = ActionScript.Expression <long>("ACTFlashGate.GetMillisecondsFromDate();");
            vulnerableTicksOnStart = ActionScript.Expression <long>("ACTFlashGate.GetMillisecondsFromStart();");

            ticksOnStart           *= TimeSpan.TicksPerMillisecond;
            vulnerableTicksOnStart *= TimeSpan.TicksPerMillisecond;
#else
            ticksOnStart           = DateTime.UtcNow.Ticks;
            vulnerableTicksOnStart = System.Environment.TickCount * TimeSpan.TicksPerMillisecond;
#endif
            prevTicks         = ticksOnStart;
            prevIntervalTicks = ticksOnStart;
        }
Пример #27
0
    public void Back()
    {
        Manager.Instance.SetUpdateSendRequests(false);

        if (_runManaAction != null)
        {
            _runManaAction.Stop(true);
            _runManaAction = null;
        }

        // Play sound
        SoundManager.PlayButtonOpen();

        TransitionManager.Instance.FadeTransitionScene(Settings.MainMenuScene);
    }
Пример #28
0
    public static void StopAction(this GameObject go, string name, bool forceEnd = false)
    {
        ActionScript[] actionScripts = go.GetComponents <ActionScript>();

        for (int i = 0; i < actionScripts.Length; i++)
        {
            ActionScript actionScript = actionScripts[i];

            if (actionScript.name == name)
            {
                actionScript.Stop(forceEnd);
                break;
            }
        }
    }
Пример #29
0
    public static void ResumeAction(this GameObject go, string name)
    {
        ActionScript[] actionScripts = go.GetComponents <ActionScript>();

        for (int i = 0; i < actionScripts.Length; i++)
        {
            ActionScript actionScript = actionScripts[i];

            if (actionScript.name == name)
            {
                actionScript.Paused = false;
                break;
            }
        }
    }
Пример #30
0
    public static void ReplayAction(this GameObject go, string name, bool reset = true)
    {
        ActionScript[] actionScripts = go.GetComponents <ActionScript>();

        for (int i = 0; i < actionScripts.Length; i++)
        {
            ActionScript actionScript = actionScripts[i];

            if (actionScript.name == name)
            {
                actionScript.Replay(reset);
                break;
            }
        }
    }
Пример #31
0
        private void DoExitWhile()
        {
            ActionScript.CSL().WhileQuery.Clear();
            ActionScript.CSL().WhileQueryInitialized = true;

            //Skip to endwhile:

            BaseOverworldScreen oS = (BaseOverworldScreen)Core.CurrentScreen;

            while (oS.ActionScript.Scripts.Count > 0 && oS.ActionScript.Scripts[0].ScriptV2.ScriptType != ScriptTypes.endwhile)
            {
                oS.ActionScript.Scripts.RemoveAt(0);
            }

            this.IsReady = true;
        }
Пример #32
0
    private void Awake()
    {
        Setup();

        ActionScript moveAction2 = gameObject.AddComponent(typeof(ActionScript)) as ActionScript;

        moveAction2.action = new UnityEngine.Events.UnityEvent();
        moveAction2.action.AddListener(BasicAttackClick);
        moveAction2.actionImage = basicAttackImage;
        skills.Add(moveAction2);

        ActionScript moveAction = gameObject.AddComponent(typeof(ActionScript)) as ActionScript;

        moveAction.action = new UnityEngine.Events.UnityEvent();
        moveAction.action.AddListener(HolyCleaveClick);
        moveAction.actionImage = specialMove1Image;
        skills.Add(moveAction);
    }
Пример #33
0
 public unsafe FrameInitAction(byte* pBuffer, byte* pBufferStart)
     : base(&pBuffer)
 {
     _clip = *(uint*)pBuffer;
     pBuffer += 4;
     byte* pActionScriptBuffer = pBufferStart + *(uint*)pBuffer;
     _script = new ActionScript(pActionScriptBuffer, pBufferStart);
 }
Пример #34
0
 /// <summary>
 /// Adds a new action script to the queue
 /// </summary>
 /// <param name="script">Script to run</param>
 public void AddActionScript(ActionScript script)
 {
     actions.Enqueue(script);
 }
Пример #35
0
        /// <summary>
        /// Base function for updating action scripts.
        /// </summary>
        /// <param name="elapsed">Time since last update</param>
        public virtual void Update(int elapsed)
        {
            // If there's currently an action script executing, update it
            if (hasAction)
            {
                if (currentScript != null)
                    currentScript.Update(elapsed);
            }
            else
            {
                // If there's an action in the queue, perform updates
                if (actions.Count > 0)
                {
                    directorTimer += elapsed;

                    // Wait for a second to allow the battle to update so the timers
                    // can increase.  This prevents a slew of actions from completely
                    // blocking.
                    if (directorTimer >= cDirectorDelay)
                    {
                        directorTimer = 0;

                        // Get the next script and link the event so we'll know when it's done
                        Console.WriteLine("[Director Update]:  Getting next action");
                        currentScript = actions.Dequeue();
                        currentScript.Start();
                        currentScript.ScriptDone += ScriptDoneHandler;

                        hasAction = true;
                    }
                }
            }
        }
Пример #36
0
	public void attackActionWantsToAttackHere(AttackScript attack, UnitScript unitAttacking){
		// Unit can't attack nothing or itself.
		if(unitInstalled != null && unitInstalled != unitAttacking){
			if(attackActionID == -1){
				attackActionID = spriteDisplayScript.displayAction(gridManager.spritesAndColors.sprite_attack);
				actionWaitingForUserInput = attack;
			} else{
				Debug.Log("attack action already displayed");
			}
		}
	}
Пример #37
0
	/// <summary>
	/// Adds the action to queue.
	/// Does not invoke any methods in action.
	/// </summary>
	/// <param name="action">Action.</param>
	public void addActionToQueue(ActionScript action){
		actionList.AddLast(action);
	}
Пример #38
0
 public unsafe FrameAction(byte* pBuffer, byte* pBufferStart)
     : base(&pBuffer)
 {
     byte* pActionScriptBuffer = pBufferStart + *(uint*)pBuffer;
     _script = new ActionScript(pActionScriptBuffer, pBufferStart);
 }
 // Use this for initialization
 void Start()
 {
     action = GetComponent <ActionScript> ();
 }
Пример #40
0
        /// <summary>
        /// Handles the event when the script is done
        /// </summary>
        /// <param name="o"></param>
        /// <param name="e"></param>
        void ScriptDoneHandler(object o, EventArgs e)
        {
            // Reset the current script and show that there's no script currently running
            currentScript = null;
            hasAction = false;

            // Signal that an action is done
            OnActionDone();
        }
Пример #41
0
 /// <summary>
 /// Adds a new action script to the queue.
 /// </summary>
 /// <param name="newAction"></param>
 public void AddAction(ActionScript newAction)
 {
     actions.Enqueue(newAction);
 }
Пример #42
0
	/// <summary>
	/// Sets the temperary action to use with user selection.
	/// does not work if unit is acting
	/// </summary>
	/// <param name="action">Action.</param>
	/// <param name="displayUserSelection">If set to <c>true</c> display user selection.</param>
	public void setTempAction(ActionScript action, bool displayUserSelection){
		if(!isActing){
			if(tempAction != null){
				tempAction.removeUserSelectionDisplay();
			}	
			tempAction = action;
			if(displayUserSelection){
				tempAction.displayUserSelection();
			}
		}
	}
Пример #43
0
	public void removeAttackDisplayForThis(){
		spriteDisplayScript.removeAction(attackActionID);
		attackActionID = -1;
		actionWaitingForUserInput = null;
	}
Пример #44
0
 public unsafe FramePlaceObjectActionScriptItem(byte** ppBuffer, byte* pBufferStart)
 {
     _event = (FramePlaceObjectEventType)(*(int*)*ppBuffer);
     *ppBuffer += 4;
     *ppBuffer += 4; // ZERO
     byte* pActionScriptBuffer = pBufferStart + *(uint*)*ppBuffer;
     *ppBuffer += 4;
     _script = new ActionScript(pActionScriptBuffer, pBufferStart);
 }
Пример #45
0
 public void AddUserScript(ActionScript.IScriptAction script)
 {
     rpg.AddScriptItem(script);
 }
 // Use this for initialization
 void Start()
 {
     actionController = GetComponent <ActionScript>();
 }