Beispiel #1
0
    /// <summary>
    /// 根据当前机器人和等级更新UI显示信息
    /// </summary>
    private void UpdateRobotUI()
    {
        Image  headI      = DIYP.Find("Robot_P/I").GetComponent <Image>();
        Text   nameT      = DIYP.Find("Robot_P/Name_T").GetComponent <Text>();
        Text   weaponT    = DIYP.Find("Robot_P/Weapon_T").GetComponent <Text>();
        Text   defenseT   = DIYP.Find("Robot_P/Defense_T").GetComponent <Text>();
        Text   speedT     = DIYP.Find("Robot_P/Speed_T").GetComponent <Text>();
        Text   otherT     = DIYP.Find("Robot_P/Other_T").GetComponent <Text>();
        Text   infoT      = DIYP.Find("Robot_P/Info_T").GetComponent <Text>();
        Text   hpT        = DIYP.Find("Robot_P/HP_T").GetComponent <Text>();
        Text   moveSpeedT = DIYP.Find("Robot_P/MoveSpeed_T").GetComponent <Text>();
        Button upgradeB   = DIYP.Find("Robot_P/Upgrade_B").GetComponent <Button>();
        Text   costT      = DIYP.Find("Robot_P/Upgrade_B/Value_T").GetComponent <Text>();

        bool isMaxLevel = RobotInfo.Instance.MainRobotInfo.robotLevel == RobotInfo.Instance.MainRobotInfo.robotMaxLevel - 1;

        headI.sprite    = ResourcesLoadManager.LoadRobotResources <GameObject>(RobotInfo.Instance.MainRobotInfo.robotResName).GetComponent <SpriteRenderer>().sprite;
        nameT.text      = RobotInfo.Instance.MainRobotInfo.robotName;
        weaponT.text    = string.Format("武器节点:{0}", RobotInfo.Instance.MainRobotInfo.weaponPoints);
        otherT.text     = string.Format("特殊节点:{0}", RobotInfo.Instance.MainRobotInfo.otherPoints);
        infoT.text      = string.Format("{0}", RobotInfo.Instance.MainRobotInfo.robotInfo);
        hpT.text        = string.Format("生命:{0}", RobotInfo.Instance.MainRobotInfo.maxHP);
        moveSpeedT.text = string.Format("速度:{0}", RobotInfo.Instance.MainRobotInfo.moveSpeed);

        upgradeB.interactable = !isMaxLevel;
        costT.text            = isMaxLevel ? "Max" : string.Format("升级:{0}", RobotInfo.Instance.MainRobotInfo.cost);
    }
Beispiel #2
0
    /// <summary>
    /// 开始游戏 初始化主角
    /// </summary>
    public void CreatePlayerAndStartGame()
    {
        IsGame  = true;
        IsPause = false;

        //如果主角精灵还存在 则销毁主角
        if (null != MainRobot)
        {
            Destroy(MainRobot);
        }

        //重置数据
        GameTime = 0;

        RobotInfo.Instance.Score = 0;
        RobotInfo.Instance.HP    = RobotInfo.Instance.MainRobotInfo.maxHP;

        string resName = RobotInfo.Instance.MainRobotInfo.robotResName;
        //根据角色数据生成主角
        GameObject robotGo = ResourcesLoadManager.LoadRobotResources <GameObject>(resName);

        MainRobot          = Instantiate(robotGo);
        MainRobotTransform = MainRobot.transform;

        MainRobotTransform.SetParent(PlayerGroup);
        MainRobotTransform.localPosition    = BEGIN_POS;
        MainRobotTransform.localEulerAngles = Vector3.zero;
        MainRobotTransform.localScale       = 5 * Vector3.one;//TODO

        MainRobot.AddComponent <RobotController>();
    }