// Use this for initialization
    void Start()
    {
        fingerPinchCount = new int[4];

        for (int i = 0; i < fingerPinchCount.Length; i++)
        {
            fingerPinchCount[i] = 0;
        }

        controller = new Controller();

        if (controller.IsConnected)
        {
            Debug.Log("Connected");
        }

        AS = this.GetComponent <AudioSource>();

        AudioPlayer = GameObject.FindGameObjectWithTag("AudioPlayer");
        Debug.Assert(AudioPlayer != null);

        AudioPlayer_AS = AudioPlayer.GetComponent <AudioSource>();
        audiomanager   = AudioPlayer.GetComponent <AudioManager>();

        actionReference = GameObject.FindGameObjectWithTag("Manager").GetComponent <GameplayActions>();
    }
示例#2
0
文件: Player.cs 项目: Knose1/Kanrythm
        /// <summary>
        /// Give the controle to the player
        /// </summary>
        public void EnablePlay()
        {
            Debug.Log("play enabled");
            doAction = DoActionNormal;

            GameplayActions control = Controller.Instance.Input.Gameplay;

            control.LockCannon.performed += LockCannon_performed;
        }
    // Use this for initialization
    void Start()
    {
        AS          = this.GetComponent <AudioSource>();
        AudioPlayer = GameObject.FindGameObjectWithTag("AudioPlayer");
        Debug.Assert(AudioPlayer != null);

        AudioPlayer_AS = AudioPlayer.GetComponent <AudioSource>();
        audiomanager   = AudioPlayer.GetComponent <AudioManager>();

        script = GameObject.Find("GameObject").GetComponent <GameplayActions>();
        if (script != null)
        {
            Setup();
        }

        Destroy(this.gameObject, 5.0f);
    }
示例#4
0
        public JsonResult ExecuteAction(String action, int heroId)
        {
            Hero          hero       = Db.Hero.Find(heroId);
            Gameplay      gameplay   = RedisContext.GetByKey <Gameplay>($"hero-gamesave-{heroId}") ?? new Gameplay(hero);
            JsonResult    jsonResult = new JsonResult();
            GameplayModel gameplayModel;

            gameplay.Player = hero;
            try
            {
                List <string> result = new GameplayActions(gameplay).ExecuteAction(action).ToList();
                if (0 == gameplay.Monsters.Count)
                {
                    gameplay.Monsters = gameplay.CurrentLocation.AmbushPlayer();
                    result.AddRange(gameplay.Monsters.Select(m => $"You have been attacked by {m.Name}"));
                }
                gameplayModel = new GameplayModel(hero, result.ToArray());
                if (!RedisContext.Save($"hero-gamesave-{gameplay.Player.ID}", gameplay))
                {
                    gameplayModel.Messages = new String[] { "There was an error while saving game." };
                }
                else
                {
                    hero.Pockets.ToList().ForEach(x => {
                        Db.Entry(x.Item.ItemInfo).State = EntityState.Modified;
                    });
                    hero.LastPlayedAt    = DateTime.UtcNow;
                    Db.Entry(hero).State = EntityState.Modified;
                    Db.SaveChanges();
                }
            }
            catch (InvalidActionException e)
            {
                gameplayModel = new GameplayModel(hero, new string[] { e.Message });
            }
            jsonResult.Data = StringHelper.SerializeObject(gameplayModel);

            return(jsonResult);
        }
示例#5
0
文件: Player.cs 项目: Knose1/Kanrythm
        override protected void DoActionNormal()
        {
            base.DoActionNormal();
            Vector3 lMousePos = Input.mousePosition;
            Vector3 lVec      = new Vector3
            {
                x = lMousePos.x - Screen.width / 2,
                y = lMousePos.y - Screen.height / 2
            };



            Debug.DrawLine(Vector3.zero, lVec, new Color(1, 0, 0, 1));
            Debug.DrawLine(Vector3.zero, vecBeforeCannonLock, new Color(0, 1, 0, 1));

            GameplayActions control = Controller.Instance.Input.Gameplay;

            if (control.LockCannon.phase == InputActionPhase.Started)
            {
                //cannon1Line.localRotation = cannon1Line.rotation;
                cannon2NoLine.transform.rotation = Quaternion.Euler(0, 0, (float)Math.Atan2(-lVec.y, -lVec.x) * Mathf.Rad2Deg);
            }
            else if (isLockCannonUp)
            {
                mouseVsCannonAngleDelta += Vector3.SignedAngle(vecBeforeCannonLock, lVec, Vector3.back);
                isLockCannonUp           = false;
            }
            else
            {
                vecBeforeCannonLock = lVec;
                transform.rotation  = Quaternion.Euler(0, 0, mouseVsCannonAngleDelta + (float)Math.Atan2(lVec.y, lVec.x) * Mathf.Rad2Deg);
            }

            cannon1Line.IsTriggered   = control.Cannon1.ReadValue <float>() != 0;
            cannon2NoLine.IsTriggered = control.Cannon2.ReadValue <float>() != 0;
        }