コード例 #1
0
    public override void OnInspectorGUI()
    {
        BloodSlider obj = (BloodSlider)target;

        DrawDefaultInspector();
        if (GUILayout.Button("扣20滴血"))
        {
            obj.Sub_20_Blood();
        }
    }
コード例 #2
0
    public void Init(JsonNode data, Troop troop, GameObject skillBtn)
    {
        SetProperty();
        mode          = Mode.battle;
        this.troop    = troop;
        this.skillBtn = skillBtn;
        tid           = data["tid"];
        size          = data["size"];
        atk           = data["atk"];
        matk          = data["matk"];
        level         = data["level"];
        current_hp    = hp = data["hp"];
        critical      = data["critical"];
        critical_coe  = data["critical_multiple"];
        atk_range     = data["atk_range"];
        atk_speed     = data["atk_speed"];
        move_speed    = data["move_speed"];
        skill1        = GetSkill(data["skill1"]);
        skill2        = GetSkill(data["skill2"]);
        type          = data["type"];

        GameObject stepDust = Instantiate(BattleManager.Instance.GetEffect("12352")) as GameObject;

        stepDust.transform.SetParent(this.transform, false);

        string bloodSliderName = troop.side == Troop.Side.my ? "MyBlood" : "EnemyBlood";

        bloodSlider = (Instantiate(BattleManager.Instance.GetHUD(bloodSliderName)) as GameObject).GetComponent <BloodSlider>();
        bloodSlider.Init(this);

        string     haloName = troop.side == Troop.Side.my ? "12380" : "12381";
        GameObject halo     = Instantiate(BattleManager.Instance.GetEffect(haloName)) as GameObject;

        Helper.AmplifyParticle(halo, radius * 2);
        halo.transform.SetParent(this.transform, false);

        transform.localScale = new Vector3(size, size, size);

        navMeshObstacle           = gameObject.AddComponent <NavMeshObstacle>();
        navMeshObstacle.carving   = true;
        navMeshObstacle.shape     = NavMeshObstacleShape.Capsule;
        navMeshObstacle.enabled   = false;
        navMeshAgent              = gameObject.AddComponent <NavMeshAgent>();
        navMeshAgent.speed        = move_speed;
        navMeshAgent.angularSpeed = 300;
        navMeshAgent.acceleration = 100;
        radius = radius * size;
        navMeshAgent.radius = navMeshObstacle.radius = radius * 1.5f;
        //rotation
        if (troop.side == Troop.Side.my)
        {
            transform.rotation = Quaternion.Euler(new Vector3(0, -90, 0));
        }
        else
        {
            transform.rotation = Quaternion.Euler(new Vector3(0, 90, 0));
        }

        if (skillBtn)
        {
            skillBtn.SetActive(true);
            EventTriggerListener.Get(skillBtn).onClick = CastSkill;
            skillBtn.transform.GetChild(1).GetComponent <Image>().fillAmount = current_hp / hp;
            allowCastSkill = skillBtn.transform.GetChild(3).gameObject;
        }
        AddGauge(500);         //初始500怒气
        //add event
        AddEvent(HeroAction.attack, "DoNormalAttack", preAtkTime);
        AddEvent(HeroAction.skill_cast, "DoSkill1", preSkill1Time);
        AddEvent(HeroAction.skill_attack, "DoSkill2", preSkill2Time);
    }