示例#1
0
    void GenerateDragonSlayer(int playerIdx, int slayerScore)
    {
        if (slayerScore == 0)
        {
            Debug.LogWarning("slayerScore��������Ϊ0");
            return;
        }

        FishGenerator fishGenrator   = GameMain.Singleton.FishGenerator;
        Player        p              = GameMain.Singleton.Players[playerIdx];
        Transform     tsPlayer       = p.transform;
        Fish          dragonSlayer   = Instantiate(Prefab_DragonSlayer) as Fish;
        Transform     tsDragonSlayer = dragonSlayer.transform;

        tsDragonSlayer.parent   = fishGenrator.transform;//��fishGenerator��Ϊ���ڵ�,����ʱ����ɾ��
        tsDragonSlayer.position = tsPlayer.position;
        tsDragonSlayer.rotation = tsPlayer.rotation * Quaternion.Euler(0F, 0F, 90f);

        Vector3 tmpPos = tsDragonSlayer.localPosition;

        tmpPos.z = -3.1F;
        tsDragonSlayer.localPosition = tmpPos;

        dragonSlayer.swimmer.Go();

        FishEx_DragonSlayer fishExDragonSlayer = dragonSlayer.GetComponentInChildren <FishEx_DragonSlayer>();

        if (fishExDragonSlayer != null)
        {
            fishExDragonSlayer.Owner   = p;
            fishExDragonSlayer.Creator = this;

            //Ч��:������ʾ���
            Transform tsTextPlayerId = fishExDragonSlayer.transform.Find("TextPlayerId");
            if (tsTextPlayerId != null)
            {
                tk2dTextMesh textPlayerID = tsTextPlayerId.GetComponent <tk2dTextMesh>();
                textPlayerID.text = (p.Idx + 1).ToString();
                textPlayerID.Commit();
            }
            else
            {
                Debug.LogError("��Ҫ��fishDragonSlayer�����·���tk2dtextmesh:TextPlayerId");
            }
        }
        else
        {
            Debug.LogError("����������gameobject������� fishExDragonSlayer.");
        }
    }
示例#2
0
    /// <summary>
    /// ��FishEx_DragonSlayer�ص�(�����¼���������)
    /// </summary>
    /// <param name="ds"></param>
    /// <param name="owner"></param>
    public void On_FishExDragonSlayerTouchFish(FishEx_DragonSlayer ds, Fish fishTouched, Player owner)
    {
        //�Ӵ�����fish�Ѿ�����
        if (fishTouched == null || !fishTouched.Attackable)
        {
            return;
        }

        if (!mSlayFishCache.ContainsKey(fishTouched.TypeIndex))
        {
            return;
        }
        //*Ϊ�˵��ú�������һ����ʱ��bullet,�dz�Ż��,����û�취,��Ϊ�ܶ�ط�ʹ���������.�Ժ���Ҫע���¼�,���ú�����д��
        GameObject tmpBulletGo = new GameObject();
        Bullet     b           = tmpBulletGo.AddComponent <Bullet>();

        b.FishOddsMulti = 1;
        b.Score         = DragonSlayerScores[owner.Idx].Val;

        fishTouched.Kill(owner, b, 0F);

        owner.GainScore(fishTouched.Odds * DragonSlayerScores[owner.Idx].Val
                        , fishTouched.Odds
                        , DragonSlayerScores[owner.Idx].Val
                        );

        //ɾ��֮ǰ������
        Destroy(tmpBulletGo);

        //dragonSlayerScore����
        DragonSlayerScores[owner.Idx].Val = 0;

        //ɾ��dragonSlayer
        ds.Clear();

        //������
        GameObject efGo     = Instantiate(Ef_DragonKilled) as GameObject;
        Vector3    worldPos = fishTouched.transform.position;

        worldPos.z = Defines.GlobleDepth_BombParticle;
        efGo.transform.position = worldPos;
    }
示例#3
0
    private Dictionary<int, Fish> mSlayFishCache; //�ɱ�ɱ����cache,��Prefab_SlayFish����

    #endregion Fields

    #region Methods

    /// <summary>
    /// ��FishEx_DragonSlayer�ص�(�����¼���������)
    /// </summary>
    /// <param name="ds"></param>
    /// <param name="owner"></param>
    public void On_FishExDragonSlayerTouchFish(FishEx_DragonSlayer ds, Fish fishTouched,Player owner)
    {
        //�Ӵ�����fish�Ѿ�����
        if (fishTouched == null || !fishTouched.Attackable)
            return;

        if (!mSlayFishCache.ContainsKey(fishTouched.TypeIndex))
            return;
        //*Ϊ�˵��ú�������һ����ʱ��bullet,�dz�Ż��,����û�취,��Ϊ�ܶ�ط�ʹ���������.�Ժ���Ҫע���¼�,���ú�����д��
        GameObject tmpBulletGo = new GameObject();
        Bullet b = tmpBulletGo.AddComponent<Bullet>();
        b.FishOddsMulti = 1;
        b.Score = DragonSlayerScores[owner.Idx].Val;

        fishTouched.Kill(owner, b, 0F);

        owner.GainScore(fishTouched.Odds * DragonSlayerScores[owner.Idx].Val
            , fishTouched.Odds
            , DragonSlayerScores[owner.Idx].Val
            );

        //ɾ��֮ǰ������
        Destroy(tmpBulletGo);

        //dragonSlayerScore����
        DragonSlayerScores[owner.Idx].Val = 0;

        //ɾ��dragonSlayer
        ds.Clear();

        //������
        GameObject efGo = Instantiate(Ef_DragonKilled) as GameObject;
        Vector3 worldPos = fishTouched.transform.position;
        worldPos.z = Defines.GlobleDepth_BombParticle;
        efGo.transform.position = worldPos;
    }