示例#1
0
 private void Awake()
 {
     player         = GameObject.Find("Player");
     thunderAbility = player.GetComponent <ThunderAbility>();
     playerHand     = player.GetComponent <CanFight>();
     nextTarget     = player;
 }
示例#2
0
    protected override void Start()
    {
        base.Start();

        ground = LayerMask.GetMask("Platform");

        coll = GetComponent <Collider2D>();
        if (coll == null)
        {
            Debug.LogError("在" + gameObject.name + "中,找不到collider");
        }

        //初始化目标层级
        layers.Add(LayerMask.NameToLayer("Player"));
        layers.Add(LayerMask.NameToLayer("Enemy"));

        //初始化canFight
        canFight = GetComponent <CanFight>();
        if (canFight == null)
        {
            Debug.LogError("在" + gameObject.name + "中,找不到canFight");
        }
        string[] targetLayer = new string[2];
        targetLayer[0] = "Player";
        targetLayer[1] = "Enemy";
        canFight.Initiailize(targetLayer);

        enabled = false;
    }
示例#3
0
    // Start is called before the first frame update
    protected virtual void Start()
    {
        //初始化CanFight
        canFight = GetComponent <CanFight>();
        if (canFight == null)
        {
            Debug.LogError("在" + gameObject.name + "中,获取canFight组件时出错");
        }

        //初始化碰撞体
        coll = GetComponent <Collider2D>();
        if (coll == null)
        {
            Debug.LogError("在" + gameObject.name + "中,找不到collider");
        }

        //检查攻击层级
        if (targetLayer.Length == 0)
        {
            Debug.LogError("在" + gameObject.name + "中,攻击层级数组未初始化");
        }

        //初始化攻击层级LayerMask列表
        for (int i = 0; i < targetLayer.Length; i++)
        {
            layerMasks.Add(LayerMask.NameToLayer(targetLayer[i]));
        }
    }
示例#4
0
 private void Start()
 {
     canFight          = enemy.GetComponent <CanFight>();
     attackComponent   = enemy.GetComponent <AttackEnemies>();
     interruptVector.x = interruptVectorX;
     interruptVector.y = interruptVectorY;
 }
示例#5
0
 public override void Initialize()
 {
     base.Initialize();
     playerAnim.SetSpell(this, SkillType.IceBlink);
     thunderAbility = player.GetComponent <ThunderAbility>();
     movementPlayer = player.GetComponent <MovementPlayer>();
     canFight       = player.GetComponent <CanFight>();
 }
 public override void Initialize()
 {
     base.Initialize();
     playerAnim.SetSpell(this, SkillType.SelfExplosion);
     defencePlayer = player.GetComponent <DefencePlayer>();
     canFight      = player.GetComponent <CanFight>();
     canBeFighted  = player.GetComponent <CanBeFighted>();
 }
示例#7
0
    //private void OnEnable()
    //{
    //    ground = LayerMask.GetMask("Platform");

    //    isRotating = false;
    //    isGo = false;
    //    isBack = false;
    //    existTime = 0f;
    //    fought.Clear();
    //}

    /// <summary>
    /// 初始化Dart,包括投掷者、目标位置,在每次生成飞镖时需要调用
    /// </summary>
    /// <param name="thrower">投掷者</param>
    public void SetThrower(GameObject thrower)
    {
        this.thrower = thrower;
        throwerHand  = thrower.GetComponent <CanFight>();
        if (throwerHand == null)
        {
            Debug.LogError("在飞镖中,投掷者没有CanFight类!");
        }
    }
示例#8
0
    /// <summary>
    /// 设置技能释放者
    /// </summary>
    /// <param name="thrower"></param>
    public void SetThrower(GameObject thrower)
    {
        this.thrower = thrower;
        canFight     = thrower.GetComponent <CanFight>();
        if (canFight == null)
        {
            Debug.LogError("在" + gameObject.name + "中,获取CanFight出错");
        }

        //transform.SetParent(thrower.transform, true);
    }
示例#9
0
    protected override void Start()
    {
        base.Start();



        speed = originalFlowSpeed;

        startPosition = transform.position;

        ground = LayerMask.GetMask("Platform");

        spriteRenderer = GetComponent <SpriteRenderer>();
        if (spriteRenderer == null)
        {
            Debug.LogError("在" + gameObject.name + "中,找不到spriteRenderer");
        }

        //颜色初始化
        originalColor      = spriteRenderer.color;
        transparentColor   = spriteRenderer.color;
        transparentColor.a = 0.0f;

        //碰撞体初始化
        coll = GetComponent <Collider2D>();
        if (coll == null)
        {
            Debug.LogError("在" + gameObject.name + "中,找不到collider");
        }

        //初始化目标层级
        layers.Add(LayerMask.NameToLayer("Player"));
        layers.Add(LayerMask.NameToLayer("Enemy"));

        //初始化canFight
        canFight = GetComponent <CanFight>();
        if (canFight == null)
        {
            Debug.LogError("在" + gameObject.name + "中,找不到canFight");
        }
        string[] targetLayer = new string[2];
        targetLayer[0] = "Player";
        targetLayer[1] = "Enemy";
        canFight.Initiailize(targetLayer);

        enabled = false;
    }
示例#10
0
    //StringBuilder targetsName = new StringBuilder();
    public override void Initialize()
    {
        base.Initialize();
        normalAttackArea = GameObject.Find("NormalAttack").GetComponent<Collider2D>();
        canFight = player.GetComponent<CanFight>();
        //使用string数组初始化canFight能够检测到的层
        string[] targets = new string[1];
        targets[0] = targetLayerName;
        canFight.Initiailize(targets);
        playerAnim.SetSpell(this, SkillType.IceSword);

        iceAbility = player.GetComponent<IceAbility>();
        iceShotFreezingZone = GameObject.Find("IceShotFreezingZone").GetComponent<BoxCollider2D>();
        if (iceShotFreezingZone == null)
        {
            Debug.LogError("iceShotFreezingZone为空");
        }
    }
示例#11
0
    private void Start()
    {
        poolManager = GameObject.Find("PoolManager").GetComponent <PoolManager>();
        if (poolManager == null)
        {
            Debug.LogError("在" + gameObject.name + "中,获取PoolManager失败");
        }

        canFight = GetComponent <CanFight>();
        if (canFight == null)
        {
            Debug.LogError("在" + gameObject.name + "中,获取CanFight失败");
        }

        //使用string数组初始化canFight能够检测到的层
        string[] targets = new string[1];
        targets[0] = "Player";
        canFight.Initiailize(targets);
    }
示例#12
0
 public void SetCanFight(CanFight canFight)
 {
     this.canFight = canFight;
 }
示例#13
0
    public override void Initialize()
    {
        //判断平台
        platformJudge = GameObject.Find("ControllerMode").GetComponent <PlatformJudge>();
        if (platformJudge == null)
        {
            Debug.LogError("找不到ControllerMode");
        }
        platform = platformJudge.GetPlatform();
        if (platform == PlatformJudge.Platfrom.ANDROID || platform == PlatformJudge.Platfrom.IOS || platform == PlatformJudge.Platfrom.WEB_MOBILE)
        {
            joystick = GameObject.Find("Variable Joystick").GetComponent <Joystick>();
            if (joystick == null)
            {
                Debug.LogError("移动端获取摇杆失败!");
            }

            aButton = GameObject.Find("AButton").GetComponent <MainElementButton>();
            bButton = GameObject.Find("BButton").GetComponent <SupportingElementButton>();
            cButton = GameObject.Find("CButton").GetComponent <SupportingElementButton>();

            jumpButton     = GameObject.Find("JumpButton").GetComponent <SimpleButton>();
            interactButton = GameObject.Find("InteractButton").GetComponent <SimpleButton>();
        }

        canFight = GetComponent <CanFight>();
        if (canFight == null)
        {
            Debug.LogError("在" + gameObject.name + "中,找不到CanFight组件!");
        }

        //使用string数组初始化canFight能够检测到的层
        string[] targets = new string[1];
        targets[0] = targetLayerName;
        canFight.Initiailize(targets);


        movementComponent = GetComponent <MovementPlayer>();
        if (movementComponent == null)
        {
            Debug.LogError("在Player中,没有找到MovementPlayer脚本!");
        }
        abilityManager = GetComponent <ElementAbilityManager>();
        //attackComponent = GetComponent<AttackPlayer>();
        //if (attackComponent == null)
        //{
        //    Debug.LogError("在Player中,没有找到AttackPlayer脚本!");
        //}

        defenceComponent = GetComponent <DefencePlayer>();
        if (defenceComponent == null)
        {
            Debug.LogError("在Player中,没有找到DefencePlayer脚本!");
        }
        defenceComponent.Initialize(5);

        interactivePlayer = GetComponent <InteractivePlayer>();

        //初始化心心数
        GameObject HpPanel = GameObject.Find("HP Panel");

        hpArray = new HPItem[defenceComponent.getHpMax()];

        for (int i = 0; i < defenceComponent.getHp(); i++)
        {
            Transform hpItem = HpPanel.transform.GetChild(i);
            hpArray[i] = hpItem.GetComponent <HPItem>();
            hpArray[i].Getting();
        }
    }
示例#14
0
 public void SetThrower(GameObject who)
 {
     thrower     = who;
     throwerHand = who.GetComponent <CanFight>();
 }
示例#15
0
    protected virtual void Awake()
    {
        player = GameObject.Find("Player");

        canFight = player.GetComponent <CanFight>();
    }