Esempio n. 1
0
        public void ShouldHaveANickName()
        {
            var sut = new PlayCharacter();

            // Assert.That(sut.Name, Is.Not.Empty);
            Assert.That(sut.NickName, Is.Null);
        }
Esempio n. 2
0
    void Start()
    {
        //获取控制盘相关对象
        ctrImg   = Ctr.GetComponent <Image>();
        pointImg = CPoint.GetComponent <Image>();
        arrowImg = Arrow.GetComponent <Image>();
        //获取玩家的移动脚本
        PlayerC = GameObject.FindObjectOfType <PlayCharacter>();
        //GameObject CameraTarget = GameObject.FindGameObjectWithTag("CameraTarget");
        cameraF = GameObject.FindObjectOfType <CFollow>();
        //MainCamera = Camera.main.transform;
        //得到坐标转换因子
        w        = GameManager.Instance.wRatio;
        h        = GameManager.Instance.hRatio;
        ScrnSize = GameManager.Instance.screenSize;//屏幕尺寸
        //print("W:" + w + ", H: " + h + "HalsScreenSize: " + ScrnSize);

        //初始化
        //Direction = Vector3.zero;
        pointMax = Ctr.sizeDelta.x * 0.5f - CPoint.sizeDelta.x * 0.5f;//控制点滑动的最远距离
        //print(maxDis);
        // 记录透明度
        a_Ctr   = ctrImg.color.a;
        a_Bar   = pointImg.color.a;
        a_Arrow = arrowImg.color.a;
        HideController();//隐藏摇杆

        temp_scaleView          = ctrlViewScale;
        Input.multiTouchEnabled = true;//开启多点触控

        //playercontrol = Player.GetComponent<playercontrol>();//windows控制不冲突用
    }
Esempio n. 3
0
 [SerializeField] ButtonNormal replay, backHome, exit;                //按钮
 //GameObject miniMap;
 // Use this for initialization
 void Start()
 {
     player = GameObject.FindObjectOfType <PlayCharacter>();
     gamec  = GameObject.FindObjectOfType <GameControl>();
     //miniMap = GameManager.Instance.UICanvas.Find("miniMap").gameObject;
     Initialize();
 }
Esempio n. 4
0
    IEnumerator _showTxt;                //逐字显示对话内容的协程
    //private ButtonTouch attackButton;//攻击按钮

    //float spd = 5;//弹出速度
    //bool txtEnd;//判断当前文字是否显示完毕

    //Gradient GCColor;//渐变颜色控制
    private void Initialize()//初始化
    {
        player = GameObject.FindObjectOfType <PlayCharacter>();
        if (null == chatRect)
        {
            GameObject _chatRect = Resources.Load <GameObject>("Prefabs/GameUI-ChatRect"); //读取
            chatRect = Instantiate(_chatRect).GetComponent <Image>();                      //实例化,赋值
            chatRect.transform.SetParent(GameManager.Instance.UICanvas, false);            //设置为画布的子物体
            chatRect.GetComponent <ButtonNormal>().onClick.AddListener(clickChatRect);     //添加横幅的点击事件
            a_rect          = chatRect.color.a;
            chatRect.color -= new Color(0, 0, 0, a_rect);                                  //全透明化
        }

        //获取对象
        //Chat_Button = GameObject.Find("Canvas/Buttons/Button_Chat").GetComponent<ButtonNormal>();
        Chat_Name = chatRect.transform.GetChild(0).GetComponent <Image>();
        a_name    = Chat_Name.color.a;

        Chat_Text = chatRect.transform.GetChild(1).GetComponent <Text>();
        Chat_Head = chatRect.transform.GetChild(2).GetComponent <RectTransform>();

        touch_Control = GameObject.FindObjectOfType <TouchControl>();
        gCtrl         = GameObject.FindObjectOfType <GameControl>();
        attackButton  = GameObject.FindObjectOfType <ButtonAttack>();
        Chat_Button   = attackButton.transform.parent.Find("ButtonChat").GetComponent <ButtonNormal>();
        Chat_Button.onClick.AddListener(EnterChat);//添加点击事件
        //attackButton = GameObject.FindObjectOfType<ButtonTouch>();
    }
Esempio n. 5
0
    void Awake()
    {
        //获取变量
        //items = GetComponentsInChildren<ItemGrid>();
        //获取信息框
        info_Name        = info.GetChild(1).GetComponentInChildren <Text>();
        info_Detail      = info.GetChild(2).GetComponentInChildren <Text>();
        info_Image       = info.GetChild(0).GetComponent <Image>();
        info_Image.color = new Color(1, 1, 1, 0);
        info_Btn         = info.GetComponentInChildren <ButtonNormal>();
        info_Btn.gameObject.SetActive(false);//隐藏按钮
        //print("Length of Items: "+items.Length);

        player = GameObject.FindWithTag("Player").GetComponent <PlayCharacter>();

        cnsmbs = BagManager.Instance.LoadConsumByXml();
        if (null == cnsmbs || cnsmbs.Count < 1)//如果没有
        {
            info_Detail.text = "没有任何物品";
            info_Image.color = new Color(1, 1, 1, 0);

            delete_Btn.gameObject.SetActive(false);
            sort_Btn.gameObject.SetActive(false);

            return;
        }
        else
        {
            GetItems();
        }
        //初始未选
        //InselectAll();
    }
Esempio n. 6
0
 // Use this for initialization
 void Start()
 {
     player          = GameObject.FindGameObjectWithTag("Player");
     amount          = 0;
     nowischangemode = false;
     //turnto2d= Quaternion.LookRotation(cameratarget.transform.forward);//转换成四元数
     cc = player.GetComponent <PlayCharacter>();
 }
Esempio n. 7
0
        public void ShouldHaveTwoBows()
        {
            var sut = new PlayCharacter();

            Assert.That(sut.Weapons, Has.Exactly(2).EndsWith("Bow"));

            //TODO: Unit Testing for Collections
            //Assert.That(sut.Weapons, Has.Exactly(1).Items.Empty);
        }
Esempio n. 8
0
 public void ChangeCharacterJob(PlayCharacter nextPlaycharacter)
 {
     if ((int)nextPlaycharacter < 3)
     {
         curPlayCharacter = playerCharacters[(int)nextPlaycharacter];
         InputManager.Ins.playGameObject   = curPlayCharacter;
         InputManager.Ins.curPlayCharacter = InputManager.Ins.playGameObject.GetComponent <PlayableCharacter>();
     }
 }
Esempio n. 9
0
    private void OnTriggerEnter(Collider other)//其他对象和该触发器碰撞时
    {
        PlayCharacter playCharacter = other.GetComponent <PlayCharacter>();

        if (playCharacter != null)
        {
            playCharacter.Hurt(damage);
        }
        Destroy(this.gameObject);
    }
Esempio n. 10
0
        public void SouldIncreaseHealthAfterSleeping()
        {
            var sut = new PlayCharacter {
                Health = 100
            };

            sut.Sleep();

            Assert.That(sut.Health, Is.GreaterThan(100));
        }
Esempio n. 11
0
        public void ReferenceEqualityTest()
        {
            var p1 = new PlayCharacter();
            var p2 = new PlayCharacter();

            // Assert.That(p1, Is.SameAs(p2));

            //var somePlayer = p1;
            //Assert.That(p1, Is.SameAs(somePlayer));

            Assert.That(p1, Is.Not.SameAs(p2));
        }
Esempio n. 12
0
    // Update is called once per frame
    void Update()
    {
        timeCount += Time.deltaTime;
        if (alive)
        {
            //如果不在地板(在空中)就掉落
            if (!onFloor)
            {
                transform.Translate(0, gravity, speed * Time.deltaTime);
            }
            else
            {
                transform.Translate(0, 0, speed * Time.deltaTime);
            }
            Ray        ray = new Ray(transform.position, transform.forward);
            RaycastHit hit;

            if (Physics.SphereCast(ray, 0.75f, out hit))
            {
                GameObject hitObject = hit.transform.gameObject;
                if (hitObject.GetComponent <PlayCharacter>())//检查目标对象是否是玩家(玩家在面前)
                {
                    foundPlayer = true;
                    player      = hitObject.GetComponent <PlayCharacter>();
                    if (fireball == null)
                    {
                        fireball = Instantiate(fireballPrefab) as GameObject;
                        fireball.transform.position = transform.TransformPoint(Vector3.forward * 1.5f);
                        fireball.transform.rotation = transform.rotation;
                    }
                }
                if (foundPlayer)
                {
                    //发现玩家后,每次都会逼近玩家
                    transform.forward = player.transform.position - transform.position;
                }
                else if ((int)timeCount % 4 == 0)
                {
                    float angle = UnityEngine.Random.Range(-30, 30);
                    transform.Rotate(0, angle, 0);
                    timeCount += 1;
                }

                if (hit.distance < obstacleRange)
                {
                    float angle = UnityEngine.Random.Range(-110, 110);
                    transform.Rotate(0, angle, 0);
                }
            }
        }
    }
Esempio n. 13
0
        public void ShouldIncreaseHealthInExpectedRangeAfterSleeping()
        {
            var sut = new PlayCharacter {
                Health = 100
            };

            sut.Sleep();
            Assert.That(sut.Health, Is.InRange(101, 200));

            /* ALSO AVAILABLE
             * Is.GreaterThanOrEqualTo()
             * Is.LessThan()
             * Is.LessThanOrEqualTo()
             */
        }
Esempio n. 14
0
 void Start()
 {
     playC       = GameObject.FindObjectOfType <PlayCharacter>();
     playerSkill = playC.GetComponent <PlayerSkills>();
     setSkillwithIndex(skillIndex);
     //print("Player: " + playerSkill.name);
     //onSkill = new UnityEvent();
     if (!enable)
     {
         ResetCD();
     }
     else
     {
         EnableSkill();
     }
 }
Esempio n. 15
0
    ButtonNormal HeadIcon;                          //头像图标

    // Use this for initialization
    void Start()
    {
        tchScrn = GameObject.Find("Canvas/TouchControl").GetComponent <TouchControl>();
        bkgImg  = GetComponent <Image>();
        //clckPanel = GetComponent<ClickPanel>();
        //添加事件
        onClickOrEsc.AddListener(DisplayWindow_Option);
        Time.timeScale = 1;
        //gameState = GameState.gaming;

        //获取玩家
        player   = GameObject.FindObjectOfType <PlayCharacter>();
        HeadIcon = GameObject.Find("Canvas/Head").GetComponent <ButtonNormal>();
        //重新读取界面信息
        GameManager.Instance.loadCanvas();
        //获取画布
        cvs = GameManager.Instance.UICanvas;
    }
Esempio n. 16
0
    // Use this for initialization
    void Start()
    {
        for (int i = 0; i < transform.childCount; i++)
        {
            GameObject child = transform.GetChild(i).gameObject;
            child.SetActive(true);
            //Debug.Log(child.name);
        }

        //获取组件
        if (null == player)
        {
            player = GameObject.FindObjectOfType <PlayCharacter>();
        }
        // if (null == txt_Energy) txt_Energy = transform.Find("Info/Text_Energy").GetComponent<Text>();
        // if (null == txt_Life) txt_Life = transform.Find("Info/Text_Life").GetComponent<Text>();
        // if (null == bar_Energy) bar_Energy = transform.Find("Info/Bar_Energy").GetComponent<ValueBar>();
        // if (null == bar_Life) bar_Life = transform.Find("Info/Bar_Life").GetComponent<ValueBar>();
        // if (null == txt_AttackPower) txt_AttackPower = transform.Find("Info/Text_AttackPower").GetComponent<Text>();


        // bar_Life.gameObject.SetActive(true);
        // bar_Energy.gameObject.SetActive(true);


        //初始化
        bar_Life.SetValue(0);
        bar_Life.Hide(0.1f, true);
        bar_Energy.SetValue(0);
        bar_Energy.Hide(0.1f, true);

        //赋值
        bar_Life.SetValue(player.life / player.maxLife);
        bar_Life.Display(1, true);
        txt_Life.text = ((int)player.life).ToString() + "/" + ((int)(player.maxLife)).ToString();

        bar_Energy.SetValue(player.energy / player.maxEnergy);
        bar_Energy.Display(1, true);
        txt_Energy.text = ((int)player.energy).ToString() + "/" + ((int)(player.maxEnergy)).ToString();

        AttackPower.text = player.attackPower.ToString();
    }
Esempio n. 17
0
 void Start()
 {
     character = GetComponent <PlayCharacter>();
 }
Esempio n. 18
0
        public void ShouldBeNewbie()
        {
            var sut = new PlayCharacter();

            Assert.That(sut.IsNoob, Is.True);
        }
Esempio n. 19
0
        public void BeforeEachTest()
        {
            Console.WriteLine("Before {0}", TestContext.CurrentContext.Test.Name);

            _sut = new PlayCharacter();
        }
Esempio n. 20
0
 // Use this for initialization
 void Start()
 {
     PlayerC       = GetComponent <PlayCharacter>();
     animator      = PlayerC.animator;
     scaleofskill3 = skilll3show.transform.localScale;
 }
Esempio n. 21
0
        public void ShouldNotHaveAStaffOfWonder()
        {
            var sut = new PlayCharacter();

            Assert.That(sut.Weapons, Has.None.EqualTo("Staff of Wonder"));
        }
Esempio n. 22
0
        public void ShouldBeOrderedAlphabetically()
        {
            var sut = new PlayCharacter();

            Assert.That(sut.Weapons.OrderBy(x => x), Is.Ordered);
        }
Esempio n. 23
0
 public void SetPlayer(Transform player) //设置玩家
 {
     playC = player.GetComponent <PlayCharacter>();
 }
Esempio n. 24
0
        public void ShouldHaveDefaultRandomGeneratedName()
        {
            var sut = new PlayCharacter();

            Assert.That(sut.Name, Is.Not.Empty);
        }
Esempio n. 25
0
        public void ShouldWeaponsBeUnique()
        {
            var sut = new PlayCharacter();

            Assert.That(sut.Weapons, Is.Unique);
        }
Esempio n. 26
0
        public void ShouldHaveALongBow()
        {
            var sut = new PlayCharacter();

            Assert.That(sut.Weapons, Contains.Item("Long Bow"));
        }
Esempio n. 27
0
    public string objName;         //拿起的物品名称

    // Use this for initialization
    void Start()
    {
        playCh    = GetComponent <PlayCharacter>();
        playAnmtr = playCh.animator;
    }