Exemple #1
0
    public void BaseInit(string name, string description, string meshPath, bool allowCollision = true)
    {
        this.name        = name;
        this.description = description;
        this.Connect("body_entered", this, nameof(OnCollide));

        this.stack = new List <int>();

        SetCollision(allowCollision);
        InitArea();
        speaker = new Speaker();
        AddChild(speaker);

        meshInstance      = new MeshInstance();
        meshInstance.Mesh = ResourceLoader.Load(meshPath) as Mesh;
        AddChild(meshInstance);

        collisionShape = new CollisionShape();
        AddChild(collisionShape);
        collisionShape.MakeConvexFromBrothers();
    }
Exemple #2
0
    /* Construct node tree. */
    protected void InitChildren()
    {
        // MeshInstance
        string meshPath = ActorMeshPath;

        meshInstance      = new MeshInstance();
        meshInstance.Mesh = ResourceLoader.Load(meshPath) as Mesh;
        AddChild(meshInstance);

        // CollisionShape
        collisionShape = new CollisionShape();
        AddChild(collisionShape);
        collisionShape.MakeConvexFromBrothers();

        // Eyes
        Spatial eyesInstance;

        if (brainType == Brains.Player1)
        {
            Camera cam = new Camera();
            cam.Far      = 1000f; // Render EVERYTHING possible
            eyesInstance = (Spatial)cam;
        }
        else
        {
            eyesInstance = new Spatial();
        }

        eyesInstance.Name = "Eyes";
        AddChild(eyesInstance);
        Vector3 eyesPos = EyesPos();

        eyesInstance.TranslateObjectLocal(eyesPos);
        eyes = eyesInstance;
        eyes.SetRotationDegrees(new Vector3(0, 0, 0));

        // Speaker
        speaker = new Speaker();
        AddChild(speaker);
    }