Esempio n. 1
0
    // Use this for initialization
    void Start()
    {
        addAction = new RepeatAction(2, () => {
            lineList.Add(Random.value + 0.1f);
            lineList.Add(-Random.value - 0.1f);
        });
        shootAction = new RepeatAction(0.65f, () => {
            for (int i = 0; i < lineList.Count; i++)
            {
                GameObject obj = AddBullet(1, false);

                obj.transform.Translate(new Vector3(0, 6.7f));
                obj.AddComponent <StrightBullet>();
                obj.GetComponent <StrightBullet>().setDirection(270 + lineList[i]);
                obj.GetComponent <StrightBullet>().setSpeed(4.5f);

                if (lineList[i] < 0)
                {
                    lineList[i] -= 9f;
                }
                else
                {
                    lineList[i] += 9f;
                }

                if (Mathf.Abs(lineList[i]) >= 90)
                {
                    lineList.RemoveAt(i);
                    i--;
                }
            }
        });
    }
Esempio n. 2
0
    public List <Directions> GetMoveDirections()
    {
        List <Directions> moveActions = new List <Directions>();

        for (int i = 0; i < actionList.Count; i++)
        {
            if (actionList[i].GetComponent <MoveAction>())
            {
                moveActions.Add(actionList[i].GetComponent <MoveAction>().GetDirection());
            }

            else if (actionList[i].GetComponent <RepeatAction>())
            {
                RepeatAction repeatAction = actionList[i].GetComponent <RepeatAction>();
                for (int k = 0; k < repeatAction.TimesRepeating; k++)
                {
                    //moveActions.Add(repeatAction.GetMoveActions()[k].GetDirection());
                    for (int j = 0; j < repeatAction.GetMoveActions().Count; j++)
                    {
                        moveActions.Add(repeatAction.GetMoveActions()[j].GetDirection());
                    }
                }
            }
        }

        return(moveActions);
    }
Esempio n. 3
0
    public void OnHint()
    {
        gameObject.StopAction("hint", true);

        var zoom   = ScaleAction.ScaleTo(hintScale, 0.1f, Ease.Linear, LerpDirection.PingPong);
        var action = RepeatAction.Create(zoom, 3, false);

        gameObject.Play(action).name = "hint";
    }
Esempio n. 4
0
        private void Repeat(RepeatAction <int, string> func, int counts, string sss)
        {
            int count = 0;

            while (count++ < 3)
            {
                func(counts, sss);
            }
        }
Esempio n. 5
0
 // Use this for initialization
 void Start()
 {
     repeatAction = new RepeatAction(0.04f, () =>
     {
         GameObject obj = AddBullet(Random.Range(1, 5), false);
         obj.AddComponent <StrightBullet>();
         obj.GetComponent <StrightBullet>().setDirection(Random.Range(0.0f, 360.0f));
         obj.GetComponent <StrightBullet>().setSpeed(Random.Range(1.0f, 8.0f));
     });
 }
Esempio n. 6
0
    // Use this for initialization
    void Start()
    {
        repeatAction = new RepeatAction(0.85f, () => {
            GameObject obj = AddBullet(2, true);

            obj.AddComponent<StrightBullet>();

            obj.GetComponent<StrightBullet>().setDirection(Random.value * 360);
            obj.GetComponent<StrightBullet>().setSpeed(3);
        });
    }
        protected override void OnDispose()
        {
            base.OnDispose();
            if (null != mRepeatAction)
            {
                mRepeatAction.Dispose();
            }

            mRepeatAction = null;
            mSequenceNode = null;
        }
Esempio n. 8
0
    void Start()
    {
        if (actions != null)
        {
            int count = actions.Length;

            if (count > 0)
            {
                BaseAction action;

                if (count == 1)
                {
                    action = actions[0].GetAction();
                }
                else
                {
                    BaseAction[] baseActions = new BaseAction[count];

                    for (int i = 0; i < count; i++)
                    {
                        baseActions[i] = actions[i].GetAction();
                    }

                    action = SequenceAction.Create(baseActions);
                }

                if (repeat != 0)
                {
                    if (delay > 0)
                    {
                        gameObject.Play(SequenceAction.Create(DelayAction.Create(delay), RepeatAction.Create(action, repeat)));
                    }
                    else
                    {
                        gameObject.Play(RepeatAction.Create(action, repeat));
                    }
                }
                else
                {
                    if (delay > 0)
                    {
                        gameObject.Play(SequenceAction.Create(DelayAction.Create(delay), action));
                    }
                    else
                    {
                        gameObject.Play(action);
                    }
                }
            }
        }

        Destroy(this);
    }
Esempio n. 9
0
    // Use this for initialization
    void Start()
    {
        repeatAction = new RepeatAction(1.5f, () => {
            Vector3 bPos = transform.position;
            Vector3 pPos = GameObject.Find("RedStar").transform.position;

            Vector3 dirVec = pPos - bPos;

            float dir = 0;

            if (dirVec.x == 0)
            {
                if (dirVec.y > 0)
                {
                    dir = 90;
                }
                else
                {
                    dir = 270;
                }
            }
            else
            {
                float t = dirVec.y / dirVec.x;

                if (dirVec.x > 0)
                {
                    dir = Mathf.Atan(t) * Mathf.Rad2Deg + Mathf.PI * 2;
                    if (dir > Mathf.PI * 2)
                    {
                        dir -= Mathf.PI * 2;
                    }
                }
                else
                {
                    dir = Mathf.Atan(t) * Mathf.Rad2Deg + 180;
                }
            }

            for (int i = 0; i < 4; i++)
            {
                for (int j = 0; j < 5; j++)
                {
                    GameObject obj = AddBullet(3, false);
                    obj.AddComponent <StrightBullet>();

                    obj.GetComponent <StrightBullet>().setDirection(dir + (i - 1) * 90);
                    obj.GetComponent <StrightBullet>().setSpeed((j + 1) * 1.2f);
                }
            }
        });
    }
Esempio n. 10
0
    // Use this for initialization
    void Start()
    {
        repeatAction = new RepeatAction(3f, () => {
            for (float d = 0; d < 360; d += 45)
            {
                GameObject obj = AddBullet(2, true);
                obj.AddComponent <StrightBullet>();

                obj.GetComponent <StrightBullet>().setDirection(d);
                obj.GetComponent <StrightBullet>().setSpeed(3.5f);
            }
        });
    }
Esempio n. 11
0
    // Use this for initialization
    void Start()
    {
        repeatAction = new RepeatAction(1f, () => {
            for (int i = 0; i < 3; i++)
            {
                GameObject obj = AddBullet(2, false);

                obj.AddComponent <StrightBullet>();

                obj.GetComponent <StrightBullet>().setDirection(dir + 120 * i);
                obj.GetComponent <StrightBullet>().setSpeed(3.5f);
            }
            dir += 17;
        });
    }
Esempio n. 12
0
    // Use this for initialization
    void Start()
    {
        repeatAction = new RepeatAction(0.85f, () => {
            for (int i = 0; i < 3; i++)
            {
                GameObject obj = AddBullet(1, false);

                obj.AddComponent <CurvedBullet>();

                obj.GetComponent <CurvedBullet>().setDirection(dir + 120 * i);
                obj.GetComponent <CurvedBullet>().setSpeed(4);
                obj.GetComponent <CurvedBullet>().setRotation(-0.4f);
            }
            dir += 17;
        });
    }
Esempio n. 13
0
    // Use this for initialization
    void Start()
    {
        repeatAction = new RepeatAction(1f, () => {
            GameObject obj = AddBullet(1, true);
            obj.transform.Translate(new Vector3(-5.5f, 4.0f));
            obj.AddComponent <StrightBullet>();
            obj.GetComponent <StrightBullet>().setDirection(0);
            obj.GetComponent <StrightBullet>().setSpeed(4);


            obj = AddBullet(1, true);
            obj.transform.Translate(new Vector3(-5.5f, -4.0f));
            obj.AddComponent <StrightBullet>();
            obj.GetComponent <StrightBullet>().setDirection(0);
            obj.GetComponent <StrightBullet>().setSpeed(4);
        });
    }
Esempio n. 14
0
    // Use this for initialization
    void Start()
    {
        repeatAction = new RepeatAction(0.7f, () => {
            GameObject obj = AddBullet(2, false);
            obj.transform.Translate(new Vector3(5.2f, 6.7f));
            obj.AddComponent <StrightBullet>();
            obj.GetComponent <StrightBullet>().setDirection(180 + 45 + error);
            obj.GetComponent <StrightBullet>().setSpeed(4.5f);

            obj = AddBullet(2, false);
            obj.transform.Translate(new Vector3(-5.2f, 6.7f));
            obj.AddComponent <StrightBullet>();
            obj.GetComponent <StrightBullet>().setDirection(270 + 45 + error);
            obj.GetComponent <StrightBullet>().setSpeed(4.5f);

            obj = AddBullet(1, false);
            obj.transform.Translate(new Vector3(-5.2f, -6.7f));
            obj.AddComponent <StrightBullet>();
            obj.GetComponent <StrightBullet>().setDirection(0 + 45 + error);
            obj.GetComponent <StrightBullet>().setSpeed(4.5f);

            obj = AddBullet(1, false);
            obj.transform.Translate(new Vector3(5.2f, -6.7f));
            obj.AddComponent <StrightBullet>();
            obj.GetComponent <StrightBullet>().setDirection(90 + 45 + error);
            obj.GetComponent <StrightBullet>().setSpeed(4.5f);

            if (isErrorUp)
            {
                error += 1.8f;
                if (error > 15f)
                {
                    isErrorUp = false;
                }
            }
            else
            {
                error -= 1.8f;
                if (error < -15f)
                {
                    isErrorUp = true;
                }
            }
        });
    }
Esempio n. 15
0
    // Use this for initialization
    void Start()
    {
        lastHolePosition = 0;
        repeatAction     = new RepeatAction(3f, () => {
            lastHolePosition = Mathf.Max(Mathf.Min(3.5f, lastHolePosition), -3.5f);
            lastHolePosition = Random.value * 4 - 2 + lastHolePosition;
            lastHolePosition = Mathf.Min(5.5f, Mathf.Max(-5.5f, lastHolePosition));

            for (float x = -5.3f; x < 5.5f; x += 0.4f)
            {
                if (Mathf.Abs(x - lastHolePosition) > 0.7f)
                {
                    GameObject obj = AddBullet(4, true);
                    obj.transform.Translate(new Vector3(x, 6.8f));
                    obj.AddComponent <StrightBullet>();
                    obj.GetComponent <StrightBullet>().setDirection(270);
                    obj.GetComponent <StrightBullet>().setSpeed(5);
                }
            }
        });
    }
Esempio n. 16
0
    // Use this for initialization
    void Start()
    {
        repeatAction = new RepeatAction(0.9f, () => {
            for (int i = 0; i < 4; i++)
            {
                GameObject obj = AddBullet(color_parameter, false);
                if (color_parameter == 1)
                {
                    color_parameter++;
                }
                else if (color_parameter == 2)
                {
                    color_parameter--;
                }

                obj.AddComponent <CurvedBullet>();

                obj.GetComponent <CurvedBullet>().setDirection(dir + 90 * i);
                obj.GetComponent <CurvedBullet>().setSpeed(4);
                obj.GetComponent <CurvedBullet>().setRotation(-0.5f);
            }
            dir += 17;
        });
    }
Esempio n. 17
0
 public static INode FromAction(this IAction action)
 {
     return(action switch {
         DelayAction delayAction => throw new NotImplementedException(),
         KeyboardAction keyboardAction => new KeyboardNode(new KeyboardNodeViewModel {
             Keys = new AvaloniaList <byte>(keyboardAction.Keys),
             DelayAfter = keyboardAction.DelayAfter,
             DelayBefore = keyboardAction.DelayBefore,
             InputType = keyboardAction.InputType,
         }),
         MouseAction mouseAction => new MouseNode(new MouseNodeViewModel {
             Key = mouseAction.Key,
             DelayAfter = mouseAction.DelayAfter,
             DelayBefore = mouseAction.DelayBefore,
             InputType = mouseAction.InputType,
         }),
         MouseMoveAction mouseMoveAction => new MouseMoveNode(new MouseMoveNodeViewModel {
             DelayAfter = mouseMoveAction.DelayAfter,
             DelayBefore = mouseMoveAction.DelayBefore,
             Horizontal = mouseMoveAction.Horizontal,
             Vertical = mouseMoveAction.Vertical,
             MouseMoveType = mouseMoveAction.MouseMoveType,
         }),
         RepeatAction repeatAction => new RepeatNode(new RepeatNodeViewModel {
             DelayAfter = repeatAction.DelayAfter,
             DelayBefore = repeatAction.DelayBefore,
             RepeatCount = repeatAction.RepeatCount,
             SelectedNode = repeatAction.Action?.FromAction(),
         }),
         TextAction textAction => new TextNode(new TextNodeViewModel {
             Text = textAction.Text,
             DelayAfter = textAction.DelayAfter,
             DelayBefore = textAction.DelayBefore,
         }),
         _ => throw new ArgumentOutOfRangeException(nameof(action)),
     });
Esempio n. 18
0
    // Use this for initialization
    void Start()
    {
        repeatAction = new RepeatAction(0.7f, () => {
            for (int i = 0; i < 6; i++)
            {
                GameObject obj = AddBullet(color_parameter, false);
                if (i < 3)
                {
                    color_parameter = 1;
                }
                else if (i >= 3)
                {
                    color_parameter = 2;
                }

                obj.AddComponent <CurvedBullet>();

                obj.GetComponent <CurvedBullet>().setDirection(dir + 60 * i);
                obj.GetComponent <CurvedBullet>().setSpeed(4);
                obj.GetComponent <CurvedBullet>().setRotation(1.0f);
            }
            dir += 23;
        });
    }
Esempio n. 19
0
 public RepeatNodeChain(int repeatCount)
 {
     mSequenceNode = new SequenceNode();
     mRepeatAction = new RepeatAction(mSequenceNode, repeatCount);
 }
Esempio n. 20
0
    // Use this for initialization
    void Start()
    {
        target       = transform.position;
        centerBullet = AddBullet(4, true);
        centerBullet.AddComponent <StrightBullet>();

        angle      = 90;
        speed      = 1;
        bulletList = new List <GameObject>();

        strightBulletSpot = centerBullet.transform.position;
        target            = GameObject.Find("RedStar").transform.position;
        angle             = Vector3.Angle(target - centerBullet.transform.position, Vector3.right);
        if ((target - centerBullet.transform.position).y < 0)
        {
            angle = 360 - angle;
        }

        speed = (centerBullet.transform.position - target).magnitude / 2;
        centerBullet.GetComponent <StrightBullet>().setSpeed(speed);
        centerBullet.GetComponent <StrightBullet>().setDirection(angle);
        for (float a = 0; a < 360; a += 20f)
        {
            GameObject obj = AddBullet(1, false);

            obj.transform.position = centerBullet.transform.position;

            CircularOrbitBullet cob = obj.AddComponent <CircularOrbitBullet>();
            cob.SetCenter(new Vector3(Mathf.Cos(a * Mathf.Deg2Rad), Mathf.Sin(a * Mathf.Deg2Rad)) * 1 + centerBullet.transform.position);
            cob.SetRadius(1);
            cob.SetAngle(a + 180);
            cob.SetSpeed(360 / 2);

            bulletList.Add(obj);
        }

        repeatAction = new RepeatAction(2, () => {
            foreach (GameObject obj in bulletList)
            {
                Destroy(obj);
            }

            bulletList.Clear();

            strightBulletSpot = centerBullet.transform.position;
            target            = GameObject.Find("RedStar").transform.position;
            angle             = Vector3.Angle(target - centerBullet.transform.position, Vector3.right);
            if ((target - centerBullet.transform.position).y < 0)
            {
                angle = 360 - angle;
            }

            speed = (centerBullet.transform.position - target).magnitude / 2;
            centerBullet.GetComponent <StrightBullet>().setSpeed(speed);
            centerBullet.GetComponent <StrightBullet>().setDirection(angle);

            for (float a = 0; a < 360; a += 20f)
            {
                GameObject obj = AddBullet(1, false);

                CircularOrbitBullet cob = obj.AddComponent <CircularOrbitBullet>();
                cob.SetCenter(new Vector3(Mathf.Cos(a * Mathf.Deg2Rad), Mathf.Sin(a * Mathf.Deg2Rad)) * 1 + centerBullet.transform.position);
                cob.SetRadius(1);
                cob.SetAngle(a + 180);
                cob.SetSpeed(360 / 2);

                bulletList.Add(obj);
            }

            isShootStright = true;
        });

        strightBulletAction = new RepeatAction(0.1f, () => {
            if (isShootStright)
            {
                for (float a = 0; a < 360; a += 60)
                {
                    GameObject obj = AddBullet(3, false);

                    obj.AddComponent <StrightBullet>();

                    float an = Vector3.Angle(strightBulletSpot - target, Vector3.right);
                    if ((strightBulletSpot - target).y < 0)
                    {
                        an = 360 - an;
                    }
                    obj.GetComponent <StrightBullet>().setDirection(a + an);
                    obj.GetComponent <StrightBullet>().setSpeed(5.5f);
                    obj.transform.position = strightBulletSpot;
                }
            }
        });

        flagAction = new RepeatAction(0.5f, () => {
            isShootStright = false;
        });
    }
Esempio n. 21
0
 public void Register(KeyStroke key, Action <KeyEventArgs> action, bool allowRepeat = true)
 {
     keyboardActionMap[key] = new RepeatAction(action, allowRepeat);
 }
Esempio n. 22
0
    void OnStart()
    {
        if (!FB.IsLoggedIn)
        {
            // Check to show login FB
            if (UserData.Instance.ShowLoginFBTimes < 3 &&
                !Manager.Instance.isShowLoginFB &&
                UserData.Instance.Level >= 10)
            {
                UserData.Instance.ShowLoginFBTimes++;
                Manager.Instance.isShowLoginFB = true;
                Manager.Instance.ShowConfirm("Connect Facebook", "Please connect with facebook to save your progress and see your friends",
                                             (isOK) =>
                {
                    if (isOK)
                    {
                        Debug.Log("Connect FB, choosse OK ...");
                        ConnectFacebook();

                        UserData.Instance.ShowLoginFBTimes = 3;
                    }
                    else
                    {
                        Debug.Log("Cancel, no connect FB ...");
                    }
                });
            }
        }

        if (!Manager.Instance.isShowNewVersion && UserData.Instance.Level >= 4)
        {
            SCross.Instance.ShowMessage("cyrus_bean_jump", "1.6.0", (result, message) => {
            });
            Manager.Instance.isShowNewVersion = true;
        }


        if (UserData.Instance.Level > 15)
        {
            SCross.Instance.GetImage("cyrus_bean_jump", (result, message) => {
                if (result)
                {
                    SCross.Instance.ShowPopupScross();
                }
            });
        }

        Screen.sleepTimeout = SleepTimeout.NeverSleep;

        // Update Facebook
        FBManager.Instance.OnUpdate();

        // Play BGM
        SoundManager.Instance.PlayMusic(SoundID.MainMenu);

        // Sunlight
        if (sunlight != null)
        {
            // Get top
            float top = Camera.main.orthographicSize;

            // Get right
            float right = Camera.main.GetOrthographicWidth();

            sunlight.transform.position      = new Vector3(right - Random.Range(0.0f, 0.1f), top + 2.0f, 0);
            sunlight.transform.localRotation = Quaternion.Euler(0, 0, Random.Range(240.0f, 250.0f));

            int count = sunlight.transform.childCount;

            for (int i = 0; i < count; i++)
            {
                sunlight.transform.GetChild(i).localScale = new Vector3(Random.Range(9.0f, 10.0f), Random.Range(0.85f, 1.0f), 1.0f);
            }

            float startOpacity = Random.value * 0.1f;
            sunlight.SetAlpha(startOpacity, true);

            var rotate  = RotateAction.RotateBy(Random.Range(-20.0f, -25.0f), 18.0f, Ease.Linear, LerpDirection.PingPongForever);
            var fadeIn  = FadeAction.RecursiveFadeTo(Random.Range(0.6f, 0.7f), 18.0f);
            var delay1  = DelayAction.Create(6.0f);
            var fadeOut = FadeAction.RecursiveFadeTo(startOpacity, 18.0f);
            var delay2  = DelayAction.Create(6.0f);
            var fade    = SequenceAction.Create(fadeIn, delay1, fadeOut, delay2);
            var action  = ParallelAction.ParallelAll(rotate, RepeatAction.RepeatForever(fade, false));

            sunlight.Play(action);
        }

        // Get ignore raycast
        _ignoreRaycast = GameObject.FindObjectOfType <IgnoreRaycast>();

        if (!UserData.Instance.PlayedCutscene1)
        {
            UserData.Instance.PlayedCutscene1 = true;
            cutscene1.SetActive(true);
        }

        // Update Connect button
        UpdateConnectFacebook(true);

        googleAnalytics.LogScreen("Main Menu");

        _requestUpdater.Play(UpdateRequests);

        Manager.Instance.SetUpdateSendRequests(true);
    }