示例#1
0
    void Start()
    {
        string[] heroNames = new string[3] {
            "Hero Info 1", "Hero Info 2", "Hero Info 3"
        };

        for (int i = 0; i < 3; ++i)
        {
            HeroUI newUI = new HeroUI();
            newUI.uiParent      = heroDetailsContainer.transform.FindChild(heroNames[i]).gameObject;
            newUI.background    = newUI.uiParent.transform.FindChild("Background").gameObject;
            newUI.armour        = newUI.uiParent.transform.FindChild("Armour").GetComponent <UILabel>();
            newUI.name          = newUI.uiParent.transform.FindChild("Name").GetComponent <UILabel>();
            newUI.nameInterface = newUI.name.transform.FindChild("Button").GetComponent <UIButton>();
            Transform temp = newUI.uiParent.transform.FindChild("Diplomat Buttons");
            newUI.embargo     = temp.FindChild("Embargo Button").GetComponent <UIButton>();
            newUI.enterSystem = temp.FindChild("Enter System Button").GetComponent <UIButton>();
            newUI.promote     = temp.FindChild("Promote Button").GetComponent <UIButton>();
            temp             = newUI.uiParent.transform.FindChild("Infiltrator Buttons");
            newUI.otherSkill = temp.FindChild("Other Skill Button").GetComponent <UIButton>();
            newUI.spy        = temp.FindChild("Spy Button").GetComponent <UIButton>();
            newUI.strike     = temp.FindChild("Strike Button").GetComponent <UIButton>();
            temp             = newUI.uiParent.transform.FindChild("Soldier Buttons");
            newUI.claim      = temp.FindChild("Claim Button").GetComponent <UIButton>();
            newUI.guard      = temp.FindChild("Guard Button").GetComponent <UIButton>();
            newUI.invade     = temp.FindChild("Invasion Button").GetComponent <UIButton>();
            heroUIInterfaces.Add(newUI);
            ActivateHeroUI(i, false);
        }
    }
示例#2
0
    /// <summary>
    ///
    /// Refreshes the item object with the item details
    ///
    /// </summary>
    public void RefreshItemObject(HeroUI heroUI, Item _item = null)
    {
        HeroUI = heroUI;
        Item   = _item;

        notesArea.SetActive(false);

        //If item is null, displays the empty item object
        if (Item == null)
        {
            IsEmptySlot = true;

            itemImage.sprite    = emptyItemSlotImage;
            itemNameText.text   = "Empty Item Slot";
            durabilityText.text = "Durability: 0";
            notesInput.text     = "";
        }
        else
        {
            IsEmptySlot = false;

            itemImage.sprite    = Item.CardArt;
            itemNameText.text   = Item.Name;
            durabilityText.text = $"Durability: {Item.CurrentDurability}";
            notesInput.text     = Item.ItemNotes;
        }
    }
示例#3
0
    public void Setup(Hero _hero, e_teams _team, int _index, Vector2Int _position, HeroUI _heroUI)
    {
        _transform.position = new Vector3(_transform.position.x, _transform.position.y, -1);
        hero     = _hero;
        team     = _team;
        index    = _index;
        position = _position;
        ui       = _heroUI;
        Color color = _team == e_teams.Blue ? GameplayManager.Instance.Data.Colors[2] : GameplayManager.Instance.Data.Colors[3];

        ui.Setup(this, color);
        visual.sprite = hero.Graph;

        stats.Add(e_stats.Health, new Stat(e_stats.Health, hero.Health));
        stats.Add(e_stats.Speed, new Stat(e_stats.Speed, hero.Speed));
        stats.Add(e_stats.Damage, new Stat(e_stats.Damage, hero.Damage));
        stats.Add(e_stats.Range, new Stat(e_stats.Range, hero.Range));
        stats.Add(e_stats.Critic, new Stat(e_stats.Critic, hero.Critic));

        hero.Attack.Set();
        hero.Active.Set();
        hero.Passive.Set();

        UpdateUI();
    }
示例#4
0
    protected override void Start()
    {
        mAnim      = GetComponent <Animator>();
        mNavAgent  = GetComponent <NavMeshAgent>();
        mRigidBody = GetComponent <Rigidbody>();

        mRigidBody.useGravity = false;

        //配置文件
        mModel = HeroModelFactory.getHeroModel(gameObject.name);

        //从配置文件读取移动速度
        mNavAgent.speed = mModel.get(Constants.HERO_ATTR_RUNSPEED);

        //取消动画中的位移
        mAnim.applyRootMotion = false;

        //保存动画初始播放速度,只为run动画根据移动速度调整动画播放速度。
        mAnimInitSpeed = mAnim.speed;

        //动作状态机
        mStateManager = gameObject.AddComponent <StateManager>();
        mStateManager.addState(new HeroRunState());
        mStateManager.addState(new HeroChaseState());
        mStateManager.addState(new HeroIdleState());
        mStateManager.addState(new HeroJumpState());
        mStateManager.addState(new HeroAttackState());
        mStateManager.addState(new HeroDeathState());
        mStateManager.setDefaultState("HeroIdleState");

        //如果死亡,不管在什么状态下都跳转到死亡状态。
        mStateManager.setCondForState("HeroDeathState", 1, () => { return(mModel.isDead()); });

        mBloodBar = gameObject.AddComponent <HeroUI>();
    }
示例#5
0
 protected void Awake()
 {
     if (Instance != null)
     {
         Destroy(gameObject);
     }
     else
     {
         Instance = this;
     }
 }
示例#6
0
    // public Animator buttonMenuAnimator;

    void Start()
    {
        instance      = this;
        heroInventory = HeroInventory.instance;
        slots         = slotHolder.GetComponentsInChildren <HeroSlot>();
        heroInventory.onHeroSlotCountChange += slotChange;
        heroInventory.onChangeHeroData      += redrawSlotUI;
        heroIllust = heroSet.transform.GetChild(1).gameObject.GetComponent <Image>();
        heroName   = heroSet.transform.GetChild(2).GetChild(0).gameObject.GetComponent <TMPro.TextMeshProUGUI>();

        heroSet.SetActive(false);
    }
示例#7
0
 void Awake()
 {
     m_stage1     = ActiveUI.transform.GetChild(0).gameObject;
     m_stage2     = ActiveUI.transform.GetChild(1).gameObject;
     m_statusText = LockButton.GetComponentInChildren <Text>();
     m_heroUI     = new HeroUI[4];
     for (int i = 0; i < 4; i++)
     {
         Button     heroButton = m_stage1.transform.GetChild(i).GetComponent <Button>();
         GameObject card_m     = m_stage2.transform.GetChild(0).GetChild(i).gameObject;
         GameObject card_f     = m_stage2.transform.GetChild(1).GetChild(i).gameObject;
         m_heroUI[i] = new HeroUI(heroButton, card_m, card_f);
     }
 }
示例#8
0
    private void CreateHeroPiece(int _heroIndex, e_teams _team, Vector2Int _position)
    {
        Square     start    = board[_position.x, _position.y];
        GameObject instance = Instantiate(heroePiecePrefab, start.transform.position, Quaternion.identity, null);
        HeroUI     ui       = gameplayManager.UIManager.CreateHeroUI();
        HeroPiece  piece    = instance.GetComponent <HeroPiece>();

        piece.Setup(gameplayManager.Data.Heroes[_heroIndex], _team, pieces.Count, _position, ui);
        start.ChangeOccupied(instance.GetComponent <HeroPiece>());

        if (gameplayManager.Team == _team)
        {
            gameplayManager.OnYourTurn += piece.TurnDebute;
        }
        else
        {
            gameplayManager.OnEnnemyTurn += piece.TurnDebute;
        }

        pieces.Add(piece);
    }
示例#9
0
    public HeroUI CreateHeroUI()
    {
        HeroUI ui = Instantiate(heroeUIPrefab, heroUIParent).GetComponent <HeroUI>();

        return(ui);
    }
示例#10
0
    protected override void Start()
    {
        mAnim = GetComponent<Animator>();
        mNavAgent = GetComponent<NavMeshAgent>();
        mRigidBody = GetComponent<Rigidbody>();

        mRigidBody.useGravity = false;

        //配置文件
        mModel = HeroModelFactory.getHeroModel(gameObject.name);

        //从配置文件读取移动速度
        mNavAgent.speed = mModel.get(Constants.HERO_ATTR_RUNSPEED);

        //取消动画中的位移
        mAnim.applyRootMotion = false;

        //保存动画初始播放速度,只为run动画根据移动速度调整动画播放速度。
        mAnimInitSpeed = mAnim.speed;

        //动作状态机
        mStateManager = gameObject.AddComponent<StateManager>();
        mStateManager.addState(new HeroRunState());
        mStateManager.addState(new HeroChaseState());
        mStateManager.addState(new HeroIdleState());
        mStateManager.addState(new HeroJumpState());
        mStateManager.addState(new HeroAttackState());
        mStateManager.addState(new HeroDeathState());
        mStateManager.setDefaultState("HeroIdleState");

        //如果死亡,不管在什么状态下都跳转到死亡状态。
        mStateManager.setCondForState("HeroDeathState", 1, () => { return mModel.isDead(); });

        mBloodBar = gameObject.AddComponent<HeroUI>();
    }