コード例 #1
0
    public void Init(int id, MonsterPO dataPO)
    {
        // 基础数据
        this.twHit            = null;
        this.twHitInterval    = 0.0f;
        this.moveType         = (MoveType)dataPO.MoveType;
        this.destroy          = false;
        this.fixedTargetIndex = 0;
        this.idleTimer        = dataPO.MoveCool;
        this.skillTimer       = dataPO.AttackCool;
        this.disappearTimer   = (float)dataPO.DisappearTime / 1000.0f;
        this.disappearAlpha   = false;
        this.id             = id;
        this.state          = StateType.Idle;
        this.dataPO         = dataPO;
        this.hp             = dataPO.Hp;
        this.mp             = 0;
        this.score          = 0;
        this.goHead         = transform.Find("Head").gameObject;
        this.lockRescued    = false;
        this.damageWater    = false;
        this.tipsCount      = 0;
        this.randRotateTime = 3.0f;
        this.lastPlayer     = null;
        // 固定点移动配置
        if (dataPO.FixPoint.Length % 3 == 0)
        {
            fixedTargetPosition = new Vector3[dataPO.FixPoint.Length / 3];
            for (int index = 0, count = 0; index < dataPO.FixPoint.Length; ++count)
            {
                Vector3 pos = new Vector3(dataPO.FixPoint[index++], dataPO.FixPoint[index++], dataPO.FixPoint[index++]);
                fixedTargetPosition[count] = pos;
            }
        }

        // 随机移动距离
        if (dataPO.MoveDistance.Length % 2 == 0)
        {
            canMoveDistance     = new MoveDistance();
            canMoveDistance.min = dataPO.MoveDistance[0];
            canMoveDistance.max = dataPO.MoveDistance[1];
        }

        //// 动画系统
        animator = GetComponent <Animator>();
        //// 移动系统
        //if (moveType == MoveType.Walk)
        //{
        //    mvAgent = GetComponent<NavMeshAgent>();
        //    mvAgent.speed = MoveSpeed;
        //    mvAgent.SetDestination(transform.position);
        //}
        //else
        //{
        //    GetComponent<NavMeshAgent>().enabled = false;
        //}

        // 技能与Buffer系统
        skillComponent  = gameObject.AddComponent <SkillComponent>();
        bufferComponent = gameObject.AddComponent <BufferComponent>();
        List <int> skillList = new List <int>();

        skillList.Add(dataPO.SkillID1);
        skillList.Add(dataPO.SkillID2);
        skillList.Add(dataPO.SkillID3);
        skillComponent.Init(skillList);
        bufferComponent.Init();

        // 特效数据
        AddBornEffect();

        // 添加头顶UI
        AppendHeadUI();

        // 武器图标
        AppendWeaponUI();

        // 救援图标
        AppendRescueHintUI();

        // 暂时特殊处理(BOSS 朝向镜头)
        //if ((MonsterType)dataPO.MonsterType == MonsterType.Boss)
        //{
        FaceTo(Camera.main.transform.position, 0.0f);
        //}

        // Hitting Act
        hittingPartDic = new Dictionary <string, HittingPart>();
        bulletTime     = 0.0f;
        invincible     = false;

        // 刷新音效
        if (dataPO.BirthSound.Length == 2)
        {
            string sound   = dataPO.BirthSound[0];
            int    percent = dataPO.BirthSound[1].ToInt();
            int    seed    = Random.Range(1, 10000);
            if (seed > percent)
            {
                return;
            }

            Main.SoundController.FireEvent(sound);
        }
    }
コード例 #2
0
 protected override void SetupScene()
 {
     SceneContext.BackgroundColor = new Vector4(0.2f, 0.3f, 0.3f, 1);
     SceneContext.AddActor(new Actor(ScreenshotBuffer = new BufferComponent()));
 }