Exemplo n.º 1
0
    // Use this for initialization
    void Start()
    {
        _mousFun = MouseFunctions.instance;
        if (_mousFun == null)
        {
            Debug.LogWarning("Mouse function not assign in scenes!!");
        }
        _mousFun.Right_Click_Once_Event   += _mousFun_Right_Click_Once_Event;
        _mousFun.Right_Double_Click_Event += _mousFun_Right_Double_Click_Event;
        _mousFun.Left_Click_Once_Event    += _mousFun_Left_Click_Once_Event;
        _mousFun.Left_Double_Click_Event  += _mousFun_Left_Double_Click_Event;

        _bt = GetComponent <BehaviorTree>();
        if (_bt == null)
        {
            Debug.LogWarning("No BehaviorTree attach!!!");
            return;
        }

        _CC = Camera_Controller.Instance;
        if (_CC == null)
        {
            Debug.LogWarning("No camera controller!!!");
        }
        _CC.Camera_Mode_Change_Event += _Camera_Mode_Changed;

        _RichAI = GetComponent <RichAI>();
        _AIPath = GetComponent <AIPath>();
    }
Exemplo n.º 2
0
    void Awake()
    {
        mFunc = GetComponent <MouseFunctions>();
        //bhandler = GetComponent<BuildHandler> ();

        UIClickFX      = (AudioClip)(Resources.Load("Sounds/UIButtonclick", typeof(AudioClip)));
        needMoneySound = (AudioClip)(Resources.Load("Sounds/needMoney", typeof(AudioClip)));
        sourceSFX      = Camera.main.GetComponent <AudioSource>();
        BGMusic        = Camera.main.transform.GetComponentInChildren <AudioSource> ();

        //spawner = spawnObject.GetComponent<SpawnUnit> ();

        normalCursor = (Texture2D)Resources.Load("Sprites/Arrow");
        buildCursor  = (Texture2D)Resources.Load("Sprites/BuildCursor");
        attackCursor = (Texture2D)Resources.Load("Sprites/AttackCursor");

        orbGhost    = (GameObject)(Resources.Load("Towers/TowerGhosts/OrbGhost"));
        cannonGhost = (GameObject)(Resources.Load("Towers/TowerGhosts/CannonGhost"));
        laserGhost  = (GameObject)(Resources.Load("Towers/TowerGhosts/LaserGhost"));
        lightGhost  = (GameObject)(Resources.Load("Towers/TowerGhosts/LightGhost"));
        magicGhost  = (GameObject)(Resources.Load("Towers/TowerGhosts/MagicGhost"));
        iceGhost    = (GameObject)(Resources.Load("Towers/TowerGhosts/IceGhost"));

        myPN = GetComponent <PlayerNetworking> ();
        bank = GetComponent <Bank>();
    }
Exemplo n.º 3
0
    // Use this for initialization
    void Start()
    {
        activeObject = false;
        playerState  = 1;
        maxHealth    = 5;
        thiefHealth  = maxHealth;
        wizardHealth = maxHealth;
        knightHealth = 8;

        knightAlive    = true;
        thiefAlive     = true;
        wizardAlive    = true;
        deathConfirmed = false;
        spawnSmoke     = false;
        wizardChild    = gameObject.transform.GetChild(0).GetChild(0).gameObject;
        thiefChild     = gameObject.transform.GetChild(1).GetChild(0).gameObject;
        knightChild    = gameObject.transform.GetChild(2).GetChild(0).gameObject;

        grapple = GetComponent <GrapplingHook>();
        bow     = GetComponent <Bow>();
        mouseFunctionsSummonableCube = summonableCube.GetComponent <MouseFunctions>();
        playerRigidbody = gameObject.GetComponent <Rigidbody>();
        knightFunctions = gameObject.GetComponent <KnightFunctions>();

        particleCube   = summonableCube.GetComponent <ParticleSystem>();
        playerMovement = gameObject.GetComponent <PlayerMovement>();

        thiefSpeed  = 10;
        knightSpeed = 10;
        wizardSpeed = 10;
    }
Exemplo n.º 4
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            string version = GL.GetString(StringName.Version);
            int    major   = (int)version[0];
            int    minor   = (int)version[2];

            if (major <= 1 && minor < 5)
            {
                System.Windows.Forms.MessageBox.Show("You need at least OpenGL 1.5 to run this example. Aborting.", "Extensions not supported",
                                                     System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Exclamation);
                this.Exit();
            }

            GL.ClearColor(1.0f, 1.0f, 1.0f, 1.0f);
            GL.ClearDepth(1.0d);
            GL.DepthFunc(DepthFunction.Less);
            GL.MatrixMode(MatrixMode.Projection);
            GL.ShadeModel(ShadingModel.Smooth);
            GL.MatrixMode(MatrixMode.Modelview);
            GL.LoadIdentity();
            GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.One);
            GL.Hint(HintTarget.PerspectiveCorrectionHint, HintMode.Nicest);
            GL.Hint(HintTarget.PointSmoothHint, HintMode.Nicest);
            GL.Hint(HintTarget.LineSmoothHint, HintMode.Nicest);
            GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Fill);

            GL.Enable(EnableCap.DepthTest);
            GL.Enable(EnableCap.ColorMaterial);
            GL.FrontFace(FrontFaceDirection.Cw);
            GL.Enable(EnableCap.CullFace);
            //GL.Enable(EnableCap.Lighting);

            Debug.On = false;

            camera = new Camera(0.1f, 2000.0f);
            camera.Position(0, 0, 1, 0, 0, 0, 0, 1, 0);

            GL.Enable(EnableCap.Light0);
            GL.Light(LightName.Light0, LightParameter.Position, new Vector4(new Vector3(0, 0, 0)));
            GL.Light(LightName.Light0, LightParameter.Ambient, new Color4(255, 255, 255, 0));
            GL.Light(LightName.Light0, LightParameter.Diffuse, new Color4(255, 100, 0, 0));

            MouseFunctions.setPosition(new Point(Game.width >> 1, Game.height >> 1));
            Mouse.ButtonDown += new EventHandler <MouseButtonEventArgs>(mouseDownEvents);
            //Mouse.Move += new EventHandler<MouseMoveEventArgs>(Primitive.MouseMoveEvent);             // Object picking

            font       = new TrueTypeFont(new Font("Times New Roman", 20f, FontStyle.Bold), true);
            font.color = new Vector3(1.0f, 0.0f, 1.0f);

            if (!loadContent())
            {
                Core.ErrorExit("Error loading content");
            }
        }
Exemplo n.º 5
0
    void Update()
    {
        if (!isLoot)
        {
            MouseFunctions.mouseClickActions(itemId, gameObject);

            if (invItemNo != -1)
            {
                food = Inventory.instance.getItemWithInvItemId(invItemNo);
            }
        }
    }
Exemplo n.º 6
0
 void Update()
 {
     if (myPlayer == null)
     {
         myPlayer = gm.MyLocalPlayer();
     }
     else
     {
         if (kf == null)
         {
             kf = myPlayer.GetComponent <KeyboardFunctions> ();
         }
         if (mf == null)
         {
             mf = myPlayer.GetComponent <MouseFunctions> ();
         }
     }
 }
Exemplo n.º 7
0
    void Update()
    {
        if (myPlayer == null)
        {
            myPlayer = gm.MyLocalPlayer();
        }

        else
        {
            if (kf == null)
            {
                kf = myPlayer.GetComponent <KeyboardFunctions> ();
            }

            if (mf == null)
            {
                mf = myPlayer.GetComponent <MouseFunctions> ();
            }

            if (bhandler == null)
            {
                bhandler = myPlayer.GetComponent <BuildHandler> ();
            }
        }

        if (runTimer == true)
        {
            buttonHoldTime += Time.deltaTime;

            if (buttonHoldTime >= buttonThresholdTime)
            {
                SellSelected();
                runTimer       = false;
                buttonHoldTime = 0;
            }
        }
    }
Exemplo n.º 8
0
    void Awake()
    {
        //Set References
        //============================================================
        kf   = GetComponent <KeyboardFunctions> ();
        mf   = GetComponent <MouseFunctions> ();
        bank = GetComponent <Bank>();
        pn   = GetComponent <PlayerNetworking> ();

        //Pre-load Objects
        //============================================================
        //Walls
        wall2Way   = (GameObject)(Resources.Load("Walls/Wall2Way"));
        wall3Way   = (GameObject)(Resources.Load("Walls/Wall3Way"));
        wall4Way   = (GameObject)(Resources.Load("Walls/Wall4Way"));
        wallEnd    = (GameObject)(Resources.Load("Walls/WallEnd"));
        wallCorner = (GameObject)(Resources.Load("Walls/WallCorner"));
        wallSolo   = (GameObject)(Resources.Load("Walls/WallSolo"));

        wallFloorOpen  = (GameObject)(Resources.Load("Walls/WallDoorOpen"));
        wallFloorClose = (GameObject)(Resources.Load("Walls/WallDoorClose"));

        //Towers
        orbTower    = (GameObject)(Resources.Load("Towers/BasicOrbTower"));
        cannonTower = (GameObject)(Resources.Load("Towers/CannonTower"));
        laserTower  = (GameObject)(Resources.Load("Towers/LaserTower"));
        iceTower    = (GameObject)(Resources.Load("Towers/IceTower"));
        lightTower  = (GameObject)(Resources.Load("Towers/LightTower"));
        magicTower  = (GameObject)(Resources.Load("Towers/MagicTower"));

        //Audio References
        sourceSFX = Camera.main.GetComponent <AudioSource> ();

        needMoneySound   = (AudioClip)(Resources.Load("Sounds/needMoney", typeof(AudioClip)));
        cannotBuildSound = (AudioClip)(Resources.Load("Sounds/CannotBuild", typeof(AudioClip)));
    }
Exemplo n.º 9
0
 private void Awake()
 {
     instance = this;
 }
Exemplo n.º 10
0
        //public override CodeLine ToCode(ICodeFormatter Formatter)
        //{
        //    var line = new CodeLine();
        //    line.Attributes = FindMechanism;
        //    var builder = new StringBuilder();
        //    line.Frames = FrameList;
        //    line.ModelPath = GetDocumentPath(Formatter);
        //    builder.Append(line.ModelPath);
        //    builder.Append(Formatter.MethodSeparator);
        //    builder.Append(ElementType);
        //    builder.Append("(" + FindMechanism.ToString() + ")");
        //    line.ModelLocalProperty = builder.ToString();
        //    builder.Append(Formatter.MethodSeparator);

        //    if (MouseFunction == MouseFunctions.Up) line.ModelFunction = "MouseUp()";
        //    else if (MouseFunction == MouseFunctions.Down) line.ModelFunction = "MouseDown()";
        //    else line.ModelFunction = "MouseEnter()";
        //    line.ModelFunction += Formatter.LineEnding;
        //    builder.Append(line.ModelFunction);
        //    line.FullLine = builder.ToString();
        //    return line;
        //}

        public override void LoadFromXml(XmlNode node)
        {
            base.LoadFromXml(node);
            MouseFunction = (MouseFunctions)Enum.Parse(typeof(MouseFunctions), node.Attributes["MouseFunction"].Value);
        }
Exemplo n.º 11
0
    void Update()
    {
        // If weapon is loot, none of functions will be able to use, just giving infos to CameraRay
        if (!isLoot)
        {
            if (GameObject.Find("GameEditor").GetComponent <GameSceneEventHandler>().localPlayer &&
                cooldownScript == null)
            {
                localPlayer    = GameObject.Find("GameEditor").GetComponent <GameSceneEventHandler>().localPlayer;
                cooldownScript = new CooldownScript(itemId, localPlayer, swingSpeed, loadSpeed);
            }

            // Change weaponMode, NOTE: Not all weapons have second mode
            if (Input.GetKeyDown(KeyCode.X))
            {
                anim.Stop();

                if (weaponMode == 0)
                {
                    weaponMode = 1;
                }
                else
                {
                    weaponMode = 0;
                }
            }

            if (weaponMode == 0)
            {
                if (canUse)
                {
                    MouseFunctions.mouseClickActions(itemId, gameObject);
                }
                else
                {
                    // Special Event of Firearms for late reloading
                    if (zoomed && !anim.isPlaying)
                    {
                        switch (itemId)
                        {
                        case ItemId.musket:
                            musketRightFunc();
                            break;

                        case ItemId.pistov:
                            pistovRightFunc();
                            break;

                        default:
                            break;
                        }
                    }
                    else
                    {
                        if (!anim.isPlaying)
                        {
                            switch (itemId)
                            {
                            case ItemId.musket:
                                reloadMusket();
                                break;

                            case ItemId.pistov:
                                reloadPistov();
                                break;

                            default:
                                break;
                            }
                        }
                    }
                }
            }
            else
            {
                if (!anim.isPlaying)
                {
                    MouseFunctions.mouseClickActions(itemId, gameObject);
                }
            }

            if (isReloadFinished)
            {
                isReloadFinished = false;
                decreaseAmmoStack();
            }
        }
    }