コード例 #1
0
ファイル: BubbleHud.cs プロジェクト: chkob/behaviac-old
    public static BubbleHud createBubbleHud(Player p_)
    {
        GameObject   go = new GameObject();
        MeshRenderer mr = go.AddComponent <MeshRenderer>();

        mr.castShadows    = false;
        mr.receiveShadows = false;
        go.AddComponent <MeshFilter>();
        BubbleHud bh  = go.AddComponent <BubbleHud>();
        Material  mat = Resources.Load("Materials/BubbleNumber") as Material;

        mr.material = mat;

        go.name                 = "HUD";
        go.transform.parent     = p_.transform;
        go.transform.localScale = new Vector3(2.0f, 2.5f, 2.5f);

        return(bh);
    }
コード例 #2
0
ファイル: Player.cs プロジェクト: nusus/behaviac
    public bool init()
    {
        //< for bt debug
        base.Init();
        this.SetIdFlag(1);

        transform.localRotation = Quaternion.Euler(0, currentOrientation, 0);
        // find turret and barrel
        Transform turretTransform = null;
        for(int i = 0; i < transform.childCount; ++i)
        {
            Transform child = transform.GetChild(i);
            if(child.name == "Turret")
            {
                turretTransform = child;
                for(int k = 0; k < turretTransform.transform.childCount; ++k)
                {
                    Transform childOfTurret = turretTransform.GetChild(k);
                    if(childOfTurret.name == "FirePoint")
                    {
                        firePoint = childOfTurret;
                        break;
                    }
                    //<
                }
            }
            else if(child.name == "Anchor")
            {
                anchorNode = child;
            }
        }

        if(turretTransform != null)
        {
            turretCtrl = new TurretController();
            turretCtrl.turret = turretTransform;
        }

        anchorNode.transform.DetachChildren();
        GameObject flagPrefab = null;
        if(force == eGameForce.RED_FORCE)
            flagPrefab = Resources.Load("Prefabs/ForceFlagRed") as GameObject;
        else
            flagPrefab = Resources.Load("Prefabs/ForceFlagBlue") as GameObject;

        GameObject flagInstance = GameObject.Instantiate(flagPrefab) as GameObject;
        flagInstance.transform.parent = anchorNode;
        flagInstance.transform.localPosition = Vector3.zero;
        flagInstance.transform.localRotation = Quaternion.identity;

        meshTable = new Hashtable();
        gatherMeshes();

        if(behaviorTree.Length > 0)
        {
            btloadResult = btload(behaviorTree, true);
            if(btloadResult)
                btsetcurrent(behaviorTree);
            else
                Debug.LogError("Behavior tree data load failed! " + behaviorTree);
        }

        bubbleHud = BubbleHud.createBubbleHud(this);

        //< todo: trick
        int life = playerLifeCount;
        playerLifeCount = life;

        targetToMove = transform.localPosition;
        gameScore = calcGameScore();

        return true;
    }
コード例 #3
0
ファイル: Player.cs プロジェクト: chkob/behaviac-old
    public bool init()
    {
        //< for bt debug
        base.Init();
        this.SetIdFlag(1);

        transform.localRotation = Quaternion.Euler(0, currentOrientation, 0);
        // find turret and barrel
        Transform turretTransform = null;

        for (int i = 0; i < transform.childCount; ++i)
        {
            Transform child = transform.GetChild(i);
            if (child.name == "Turret")
            {
                turretTransform = child;
                for (int k = 0; k < turretTransform.transform.childCount; ++k)
                {
                    Transform childOfTurret = turretTransform.GetChild(k);
                    if (childOfTurret.name == "FirePoint")
                    {
                        firePoint = childOfTurret;
                        break;
                    }
                    //<
                }
            }
            else if (child.name == "Anchor")
            {
                anchorNode = child;
            }
        }

        if (turretTransform != null)
        {
            turretCtrl        = new TurretController();
            turretCtrl.turret = turretTransform;
        }

        anchorNode.transform.DetachChildren();
        GameObject flagPrefab = null;

        if (force == eGameForce.RED_FORCE)
        {
            flagPrefab = Resources.Load("Prefabs/ForceFlagRed") as GameObject;
        }
        else
        {
            flagPrefab = Resources.Load("Prefabs/ForceFlagBlue") as GameObject;
        }

        GameObject flagInstance = GameObject.Instantiate(flagPrefab) as GameObject;

        flagInstance.transform.parent        = anchorNode;
        flagInstance.transform.localPosition = Vector3.zero;
        flagInstance.transform.localRotation = Quaternion.identity;

        meshTable = new Hashtable();
        gatherMeshes();

        if (behaviorTree.Length > 0)
        {
            btloadResult = btload(behaviorTree, true);
            if (btloadResult)
            {
                btsetcurrent(behaviorTree);
            }
            else
            {
                Debug.LogError("Behavior tree data load failed! " + behaviorTree);
            }
        }

        bubbleHud = BubbleHud.createBubbleHud(this);

        //< todo: trick
        int life = playerLifeCount;

        playerLifeCount = life;

        targetToMove = transform.localPosition;
        gameScore    = calcGameScore();

        return(true);
    }